【发布时间】:2015-12-06 07:44:06
【问题描述】:
我想得到两列,其中 group1 具有不同的值,其中 c3= yes 和 group2 根据 group1 它具有 sum(c2) 。
c1 | c2 | c3
--------------|-----
A | 2 |yes
B | 1 |yes
A | 2 |yes
B | 1 |yes
C | 2 |no
C | 1 |no
result :
group1 | group2
---------------
A | 4
B | 2
我正在尝试这个查询,但不工作
SELECT SUM(c2) WHERE DISTINCT c1 in('A','B') and c3='yes' as 'group2' from table,
SELECT DISTINCT c1 in('A','B') as 'group1' from table
【问题讨论】: