短Sql查询以合并行

时间:2012-10-08 13:20:41

标签: sql sql-server-2008

如果我有这张桌子:

Column1 Column2     Column3 
20          NULL     3/27/2012 
NULL        50      3/27/2012
NULL        40      3/27/2012

我怎样才能把它变成:

Column1 Column2     Column3 
20          90      3/27/2012 

谢谢!

1 个答案:

答案 0 :(得分:4)

试试这个

SELECT SUM(Column1) Column1, SUM(Column2) Column2, Column3
FROM Table1
GROUP BY Column3