如果列A是Plan1,我想要汇总所有记录,否则跳过计算行。但我不知道如何跳过计算行...这是我的疑问。
Select case when columnA='Plan1' then count(columnA) else ??(how to skip to count the row) end from tableA
经验:
No Column A
1 Plan1
2 Plan1
3 Plan3
4 Plan1
回答:3
答案 0 :(得分:0)
最简单的解决方案:
SELECT Count(*)
FROM tablea
WHERE columna = 'Plan1'
替代解决方案:
SELECT Count(*) As total
, Sum(CASE WHEN columna = 'Plan1' THEN 1 ELSE 0 END) As plan1
FROM tablea