Reputation: 5
I got this table that I have made using this SQL code so far:
SELECT T.*
FROM (--Some subtable--) T
The problem I have is that I need to some a whole column together. So all I need to do is SUM(Column_Name)
. I just need that one value with the table T. But when I add that to the SELECT
, the table T just shows one line with the correct SUM
totalled up:
SELECT T.*, SUM(Column_Name)
FROM (--Some subtable--) T
So, all I need is the whole table T and the one SUM(Column_Name)
together somehow?
How can I merge the sum and table T?
Upvotes: 0
Views: 22
Reputation: 1269873
I think you want a window function:
SELECT T.*, SUM(Column_Name) OVER () as total
FROM (--Some subtable--) T
Upvotes: 1