select count(*) from (select distinct cifno from  cr_xdls where  mon_date='20130350' and  brno  like '10%' and projectsize in('01') and bal > 0 and outflag in('1','2'))
请各位大虾,将上面的语句 帮我改成,以 projectsize 字段分组格式!急!!!灰尘感谢!Oracle

解决方案 »

  1.   

    select tt.projectsize, count(*) 
    from (select distinct cifno from  cr_xdls where  mon_date='20130350' and  brno  like '10%' and projectsize in('01') and bal > 0 and outflag in('1','2')) tt
    group by tt.projectsize 
      

  2.   

    select  projectsize, count(*)  from  cr_xdls where  mon_date='20130350' and  brno  like '10%' and projectsize in('01') and bal > 0 and outflag in('1','2')
    group by projectsize 楼上这位改写的有点吓人啊,我是手机弄的,不知道ok不
      

  3.   

    重新写一下
    select projectsize,count(distinct cifno) from  cr_xdls where  mon_date='20130350' and  brno  like '10%' and projectsize in('01') and bal > 0 and outflag in('1','2'))
    ;
    按照楼主语句的理解,楼上在统计时,应该少了去除重复的操作 count(distinct cifno)
      

  4.   

    上面语句最后少了 group by projectsize 语句