This is a discussion on Newbie Question - Sum of Various Fields within the MySQL forums, part of the Database Server Software category; --> I am a little confused on how to do the following..... I have the foloowing fields: reservations price total_reservations ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I am a little confused on how to do the following..... I have the foloowing fields: reservations price total_reservations available_seats total_seats income_total income_needed payment_received 1 - In the 'total_reservations' field, I would like the sum of all of the 'reservations' fields. 2 - In the 'available_seats' field, I would like the sum of 'total_seats' minus 'total_reservations' field. 3 - In the 'income_total' field, the sum of all 'price' fields. 4 - In the 'income_needed' field, the sum of a set number ($1100.00 for example) minus the 'income_total' field. 5 - A PAID logo to display if the 'payment_received' field is not empty (or does have a value in it). Any help would be greatly appreciated. Thanks, Craig |
| ||||
| Craig Barnes wrote: >I am a little confused on how to do the following..... > > I have the foloowing fields: > reservations > price > total_reservations > available_seats > total_seats > income_total > income_needed > payment_received > > 1 - In the 'total_reservations' field, I would like the sum of all of > the 'reservations' fields. > > 2 - In the 'available_seats' field, I would like the sum of > 'total_seats' minus 'total_reservations' field. > > 3 - In the 'income_total' field, the sum of all 'price' fields. > > 4 - In the 'income_needed' field, the sum of a set number ($1100.00 > for example) minus the 'income_total' field. > > 5 - A PAID logo to display if the 'payment_received' field is not > empty (or does have a value in it). > > Any help would be greatly appreciated. > > Thanks, > Craig I'm a lot confused. Are these all fields in a database table? If so you have a serious design problem since you have a mix of detail and summary level fields. Your table should contain only the detail level fields (plus of course a suitable key). The total fields should be created dynamically in a query. Also, mysql is a RDBMS, it stores data and allows you to retrieve it in various ways. It does not "display" anything and so cannot display a logo. If you are using a programming language to retrieve the data, you may be able to use that to force whatever UI (user interface) you are using, to display a logo. |