Click to See Complete Forum and Search --> : select * and sum of a col
pelegk1
12-17-2003, 08:17 AM
can i make select and SUM at the same time when i query on mysql
the sum is on a certain col where i want to gethe sum of all the cells of that col is it possible?thanks inadvance
peleg
AdamGundry
12-17-2003, 09:40 AM
In order to use normal columns and group columns together, you need to have a "group by" clause, which means you get the sum of the column for that particular group. For example:
SELECT *, SUM('field1') FROM table1 GROUP BY field2
This will show a row for each unique value of field2, together with the sum of all the field1 entries with that value of field2.
Adam
pelegk1
12-18-2003, 01:08 AM
why is that?
i have in every row of the 'field1' values of float type
AdamGundry
12-20-2003, 05:53 AM
I can't help without seeing the query/database structure you are using.
Adam