Reputation: 16204
I have a Column Amount, I will get multiple rows with different values in that Amount column. I need a select query such that I get the SUM of all these amounts as an output.
Thanks And Regards
Upvotes: 0
Views: 443
Reputation: 332581
This:
SELECT SUM(t.amount)
FROM YOUR_TABLE t
...will return a single value, the sum of all the values in the amount column. If you want to see the sum for different groups of values, you need to add a GROUP BY clause to the query:
SELECT SUM(t.amount)
FROM YOUR_TABLE t
GROUP BY t.column
Upvotes: 1
Reputation: 838146
Use the SUM aggregrate function:
SELECT SUM(Amount) AS Total
FROM yourtable
The result will contain a single row, containing the total sum for the column.
Upvotes: 2