表Requests:
Request Status
0000001 O
0000002 F
0000003 F
0000004 O
0000005 O
要求查询出以下结果:
Num of Requests, Open, Finished
5, 3, 2
用Oracle:
select
count(*) as 'Number of Requests',
sum(decode(status, 'O', 1, 0)) as Open,
sum(decode(status, 'F', 1, 0)) as Finished
from
Requests
用MySQL:
select
count(*) as 'Number of Requests',
sum(case status when "O" then 1 else 0 END) as Open,
sum(case status when "F" then 1 else 0 END) as Finished
from
Requests
再次感谢小旋子,飞鹰战士,Sunshine,卷云溶月和长得象熊的狐狸。排名不分先后,欢迎下次继续捧场。
Request Status
0000001 O
0000002 F
0000003 F
0000004 O
0000005 O
要求查询出以下结果:
Num of Requests, Open, Finished
5, 3, 2
用Oracle:
select
count(*) as 'Number of Requests',
sum(decode(status, 'O', 1, 0)) as Open,
sum(decode(status, 'F', 1, 0)) as Finished
from
Requests
用MySQL:
select
count(*) as 'Number of Requests',
sum(case status when "O" then 1 else 0 END) as Open,
sum(case status when "F" then 1 else 0 END) as Finished
from
Requests
再次感谢小旋子,飞鹰战士,Sunshine,卷云溶月和长得象熊的狐狸。排名不分先后,欢迎下次继续捧场。