请教在一条SQL中求三种条件的和
请问如何可以一条SQL,求三种条件的和。
比如stutas分别为50,40,30,的记录数总和
现在只能分别用3条SQL语句求出,请问有没有可能在一条SQL中求出,并且分别显示出来。
------解决方案--------------------select status,count(*) from t where status in (50,40,30) group by status;
------解决方案--------------------select sum(decode(status,30,1,0)) count1,sum(decode(status,40,1,0)) count2,
sum(decode(status,50,1,0)) count3
from table
------解决方案--------------------select status,
sum(quantity)
from tablename
where status in (50,40,30)
group by status;
------解决方案--------------------up
------解决方案--------------------select sum(c) status,c from table1 where c in(50,30,40) group by c;
------解决方案--------------------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 ';
------解决方案--------------------正解
------解决方案--------------------select sum(1) as bb into #c
from table
where status in (1200,2000,6000)
group by status
select sum(bb) from #c
drop table #c
------解决方案--------------------select sum(1) as bb into #c
from table
where status in (50,30,40)
group by status
select sum(bb) from #c
drop table #c
------解决方案--------------------mark
------解决方案--------------------select status,count(status) from table where status in (50,40,30) group by status
------解决方案--------------------up
------解决方案--------------------不错。
------解决方案--------------------liang521_1985() ( ) :
select sum(1) as bb into #c
from table
where status in (50,30,40)
group by status
select sum(bb) from #c
drop table #c
============================================
这是oracle的语法??