0

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
Shadow
  • 33,525
  • 10
  • 51
  • 64
Cruz
  • 1
  • 2
  • 1
    Please do not tag spam. Clearly, if you're using MySQL, you're not using PostgreSQL and should not have added that tag. Tags have relevance and meaning here, and they should be used properly. Spamming with tags that are not relevant is a very good way to collect down-votes and get your post closed. – Ken White Oct 28 '22 at 22:58

0 Answers0