T-sql :get SUM of Columns

后端 未结 3 585
梦毁少年i
梦毁少年i 2021-01-27 15:56

I have a table that looks something like the following :

          W1  W2 w3
Gold      10    2    3              
Silver     3    1    1

but i

3条回答
  •  礼貌的吻别
    2021-01-27 16:18

    Does this do what you want?

    select t.??, t.w1, (t.w1 + t.w2) as w2, (t.w1 + t.w2 + t.w3) as w3
    from table1 t;
    

    I don't know what the name of the first column is, so I just used ??.

提交回复
热议问题