【发布时间】:2018-07-18 14:04:53
【问题描述】:
我有以下查询,我试图计算 data_set “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
【问题讨论】:
-
多个数据集与您的是/否计算有何关系?