sql 语句分组并求每组总数

表结构如下图,求mysql 和oracle 的sql 语句

select r.regionName 区域,
sum(case when d.sate = 1 then 1 else 0 end) 在线数量,
sum(case when d.sate = 0 then 1 else 0 end) 离线数量
from region r,organize o,devInfo d
where r.regionId = o.regionId
and o.organziedId = d.organzieId
group by r.regionName

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答