select 'a',sum(cs) cs from table1 where lx='a'
union all
select 'b',sum(cs) cs from table1 where lx='b'
union all
select 'c',sum(cs) cs from table1 where lx='c';

解决方案 »

  1.   

    很想问一下,用group by 的方法有什么不妥吗?
      

  2.   

    select  sum(decode(lx,'a',cs,0)) a_cs,
        sum(decode(lx,'b',cs,0)) b_cs,
        sum(decode(lx,'c',cs,0)) c_cs 
    from table1;
      

  3.   

    select  sum(decode(lx,'a',cs,0)) a_cs,
        sum(decode(lx,'b',cs,0)) b_cs,
        sum(decode(lx,'c',cs,0)) c_cs 
    from tablename;
    这样不错。