我正在尝试计算变量的特定结果。这是区域数据,我在那里有遗漏,我相信在试图计算比率时会跳过这些数据。
select date
count( case when region in ('') and sale=1 then id end),
count( case when region in ('') and sale=1 then id end)/ count(id)
from region
group by 1;
missings(''(的计数是0(但我知道有missings(,mysql中指示missings的方法是什么?
如果您想包含null值,可以执行以下操作:
select date
count( case when (region in ('') or region is null) and sale=1 then id end),
count( case when (region in ('') or region is null) and sale=1 then id end)
/ count(id)
from region
group by 1;