0

Hi,
I have a MySQL DB and I am trying to set up a report page. To do so I need to be able to add the data in 6 or 7 fields into a single field for use in a summary report.

How can I do that? SUM() seems to consider only one field at a time.

For example, if I had a zoo database with the following fields:

Date| Lions| Tigers| Bears
1/1 | 2 | 3 | 2
1/2 | 1 | 0 | 2
1/3 | 0 | 2 | 3

I would want to generate a report that would tell me the date and the total number of animals added to the zoo for that date. 1/1 = 7; 1/2 = 3; 1/3 = 5

Any ideas? All help greatly appreciated!!

- Roland

1
Contributor
1
Reply
3
Views
6 Years
Discussion Span
Last Post by rolandrogers
0

I discovered the answer, at least one way to achieve my goal.

In the SELECT statement i found that you can add fields together in the following fashion:

SELECT *, (lions + tigers + bears) AS total FROM... etc...

The virtual field "total" will give me the results of my desired calculation.

I hope this helps someone else! If there is a better way for me to do this I am open to new ideas!

Thanks.

- Roland

Hi,
I have a MySQL DB and I am trying to set up a report page. To do so I need to be able to add the data in 6 or 7 fields into a single field for use in a summary report.

How can I do that? SUM() seems to consider only one field at a time.

For example, if I had a zoo database with the following fields:

Date| Lions| Tigers| Bears
1/1 | 2 | 3 | 2
1/2 | 1 | 0 | 2
1/3 | 0 | 2 | 3

I would want to generate a report that would tell me the date and the total number of animals added to the zoo for that date. 1/1 = 7; 1/2 = 3; 1/3 = 5

Any ideas? All help greatly appreciated!!

- Roland

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.