我有一个具有这些值的表
col1 col2 col3
---------------------- ------------------- -------------------------
1 0 ADD SERVICE ACTIVITY 1
0 1 ADD SERVICE ACTIVITY 1
0 8 Docment testing 2 (C07)
我想要类似的结果
col1 col2 col3
---------------------- ------------------- -------------------------
1 1 ADD SERVICE ACTIVITY 1
0 8 Docment testing 2 (C07)
答案 0 :(得分:0)
似乎您想按列group
col3
来存储数据。我不确定col1
和col2
的结果是总和还是最大值。
--for MAX:
SELECT MAX(COL1) as col1, MAX(COL2) as col2, COL3
/*-- for SUM:
SELECT SUM(COL1) as col1, SUM(COL2) as col2, COL3
*/
FROM test
GROUP BY COL3;