按照金额不同取count在informix中如何写哦
一个表mio_logpol_code amnt
667 100
667 10
667 101
667 199
550 300
550 100
550 10
550 199
如何写sql分组能得到这样的效果呢
pol_code count(amnt>0 and amnt<=100) count(amnt>100 and amnt<=200) count(amnt>200)
667 2 2 0
550 2 1 1
求解
informix可以sum(case when .... end)好像count的时候不行哦 select pol_code,
sum(case when amnt>0 and amnt<=100 then 1 else 0 end),
sum(case when amnt>100 and amnt<=200 then 1 else 0 end),
sum(case when amnt>200 then 1 else 0 end)
from mio_log
group by 1
页:
[1]