请问如何可以一条SQL,求三种条件的和。
比如stutas分别为50,40,30,的记录数总和现在只能分别用3条SQL语句求出,请问有没有可能在一条SQL中求出,并且分别显示出来。

解决方案 »

  1.   

    select status,count(*) from t where status in (50,40,30) group by status;
      

  2.   

    select status,count(*) from t where status in (50,40,30) group by status;
      

  3.   

    select sum(decode(status,30,1,0)) count1,sum(decode(status,40,1,0)) count2,
    sum(decode(status,50,1,0)) count3
    from table
      

  4.   

    select status,
           sum(quantity)
      from tablename
     where status in (50,40,30)
     group by status;
      

  5.   

    select sum(c) status,c from table1 where c in(50,30,40) group by c;
      

  6.   

    select status,
           sum(quantity)
      from tablename
     where status in (50,40,30)
     group by status;这句对 或者用苯办法 
    select 
           sum(quantity)
      from tablename
     where status='50' or status='40' or status='30';
      

  7.   

    select sum(1) as bb into #c
      from table
     where status in (1200,2000,6000)
     group by statusselect sum(bb) from #cdrop table #c
      

  8.   

    select sum(1) as bb into #c
      from table
     where status in (50,30,40)
     group by statusselect sum(bb) from #cdrop table #c
      

  9.   

    select status,count(status) from table where status in (50,40,30) group by status
      

  10.   

    liang521_1985() ( ) : 
    select sum(1) as bb into #c
      from table
     where status in (50,30,40)
     group by statusselect sum(bb) from #cdrop table #c
    ============================================
    这是oracle的语法??