I have this table:
ColumnA | ColumnB | ColumnC | ColumnD |
---|---|---|---|
1 | 2 | 1 | 3 |
3 | 4 | 3 | 4 |
I want a to do a select like this:
Column id | sum |
---|---|
ColumnA_ | 4 |
ColumnB_ | 6 |
ColumnC_ | 4 |
ColumnD_ | 7 |
The porpuse of this is to get a column with the comumn id and another with the sum of each column
I've tried to get the sum of the columns but I couldn't get it like vertically
SELECT SUM(ColumnA ) as ColumnA_, SUM(ColumnB ) as ColumnB_, SUM(ColumnC ) as ColumnC_, SUM(ColumnD ) as ColumnD_ FROM table_name
and I get this (not what I want):
ColumnA_ | ColumnB_ | ColumnC_ | ColumnD_ |
---|---|---|---|
4 | 6 | 4 | 7 |