我有以下查询,其中我要对数据集“ 1234”的columnA为Y或N的所有实例进行计数。
select
data_set as DATA_SET,
sum(case when columnA <> '' and columnA = ‘Y’ then 1 else 0 end) as YES,
sum(case when columnA <> '' and columnA = ’N’ then 1 else 0 end) as NO
from myTable1
where data_set = 1234
group by data_set;
它返回:
data_set | YES | NO
1531587375 | 6,287,732 | 54,228,649
现在,我现在想做的是如何在同一查询中查找两个不同的data_set(ds1 = 1234,ds2 = 4321)并返回类似的内容:
Column | ds1.count | ds2.count
Y | 134,543 | 153,678
N | 5,080 | 989,820
答案 0 :(得分:0)
我想我明白了,以下对我有用:
pip