views:

55

answers:

2

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
how can i get those three rows
Johanna
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
A: 
SELECT 
SUM(table.column1) + SUM(table.column2) + SUM(table.column3) 
FROM table
Mike