to  bzszp(www.bzszp.533.net) ,
就是根据月份,批号分组统计

解决方案 »

  1.   

    你的批号是数字型的吗?
    SELECT periodid,decode(trunc(batchid/10),0,userpccount,0) '<10',
       decode(trunc(batchid/10),1,userpccount,0) '10-20',
       decode(trunc(batchid/10),2,userpccount,0) '20-30',
       decode(trunc(batchid/10),3,userpccount,0) '30-40',
       decode(trunc(batchid/10),4,userpccount,0) '40-50',
       decode(sign(trunc(batchid/10)-5),1,userpccount,0) '>50'
    from tbname
    group by periodid;
      

  2.   

    :)
    SELECT  periodid,SUM(decode(trunc(batchid/10),0,userpccount,0)  '  <10',  
         SUM(decode(trunc(batchid/10),1,userpccount,0))  '10-20',  
         SUM(decode(trunc(batchid/10),2,userpccount,0))  '20-30',  
         SUM(decode(trunc(batchid/10),3,userpccount,0))  '30-40',  
         SUM(decode(trunc(batchid/10),4,userpccount,0))  '40-50',  
         SUM(decode(sign(trunc(batchid/10)-5),1,userpccount,0))  '  >50'  
    from  tbname  
    group  by  periodid;
      

  3.   

    bzszp(www.bzszp.533.net)  大哥的已經可以了