首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

oracle count(decode(x,x,x)) group by 合用小技艺

2013-10-14 
oracle count(decode(x,x,x))group by合用小技巧selectcount(decode(mc,null,null,1)) ymcs,count(decode(

oracle count(decode(x,x,x)) group by 合用小技巧
select count(decode(mc,null,null,1)) ymcs, count(decode(mc,null,1,null)) wmcs, from totalgroup group by bh

?这句话的意思 将totalgroup表 根据小组编号bh分组

然后把小组中有名称的人(mc 不为null)人数统计和小组中没有名称的人(mc 为null)人数统计

注意这里decode(mc,null,null,1) 当值为1时才会去count null是不计入数量

热点排行