本帖最后由 jxxvah 于 2012-07-06 10:43:33 编辑

解决方案 »

  1.   

    下面这样试验一下,不对的地方,你调整一下。select BuMen sum(decode(Bumen,'财务',ChiDao,0)) from QianDao where ChiDao='1'
    union all
    select BuMen sum(decode(Bumen,'技术',ChiDao,0)) from QianDao where ChiDao='1'
    union all
    select BuMen sum(decode(Bumen,'市场',ChiDao,0)) from QianDao where ChiDao='1'
    union all
    select BuMen sum(decode(Bumen,'人事',ChiDao,0)) from QianDao where ChiDao='1';
      

  2.   

    有多少部门 添加多少部门  最好能添加一张部门表 select t1.c1,t2.count(ChiDao) 
    from 
    (
      select '财务' c1 from dual
      union all
      select '技术' c1 from dual
      union all
      select '市场' c1 from dual
      union all
      select '人事' c1 from dual
    ) t1 left join QianDao t2 on t1.c1 = t2.BuMen
    group by t1.c1
      

  3.   

    掉了where ChiDao="1"至于是count还是sum看要怎么求了 
      

  4.   

    --试试这样写,只要出现过的部门,即使没有迟到次数,也会出现在列表中
    select buMen,sum(decode(chiDao,'1',1,0)) from qianDao
    group by buMen