代码改变世界

在同一个sql语句中如何写不同条件的count数量

2009-10-20 17:46  CaiGen008  阅读(388)  评论(0编辑  收藏  举报

终于在高手的指点下,写出了下面的成果
       select
        sum(case when (t.条件字段='00') then 1 else 0 end) "描述名称1",
        sum(case when (t.条件字段='01') then 1 else 0 end) "描述名称2"
       from 表名 t