一般的,我們會在where, 或者 having中加條件,count中只是某個字段
今天看到另外一種寫法,不知道性能怎么樣
select
count( case when xxx>10 and yyy<99 then bbb else null end) cm1,
count( case when xxx>20 and yyy<1 then ccc else null end) cm2
from xxxx
基本原理是 使用了數據庫count(null)時返回的是0 count(非null)返回是1
@Flink SQL
