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';
union all
select 'b',sum(cs) cs from table1 where lx='b'
union all
select 'c',sum(cs) cs from table1 where lx='c';
sum(decode(lx,'b',cs,0)) b_cs,
sum(decode(lx,'c',cs,0)) c_cs
from table1;
sum(decode(lx,'b',cs,0)) b_cs,
sum(decode(lx,'c',cs,0)) c_cs
from tablename;
这样不错。