I have table that I want to sum 3 rows of one column how can I do that?
+4
A:
If I understand your question correctly - you should use the SUM() function
SELECT SUM(the_column)
FROM the_table
WHERE condition-to-get-your-three-rows
A "WHERE" clause will allow to specify which 3 rows you want to be summed up. Some examples of "WHERE" clauses are below:
WHERE row_id < 3
or
WHERE active = 'Yes'
So the above statement may look like
SELECT SUM(the_column)
FROM the_table
WHERE active = 'Yes'
programatique
2010-07-08 19:13:22
how can i get those three rows
Johanna
2010-07-08 19:16:43
you need to write a WHERE clause (as shown above). This clause needs to contain a condition. I've added examples to my answer above.If you can specify what 3 rows in your table you want to be summed up, I can probably help.
programatique
2010-07-09 13:22:31
A:
SELECT
SUM(table.column1) + SUM(table.column2) + SUM(table.column3)
FROM table
Mike
2010-07-08 19:14:12