原帖由 gqywf 于 2006-3-7 08:59 发表
(
SELECT student, count( mark ) , count( fen )
FROM DATA WHERE mark >60
GROUP BY class
)
UNION (
SELECT student, count( mark ) , count( fen )
FROM DATA WHERE fen =70
GROUP BY class
...
原帖由 rardge 于 2006-3-7 15:01 发表
select classid, count(case when mark > 60 then 1 end) as m, count(case when fen > 70 then 1 end) as f from tbname group by classid
受 Namelessxp 启发而写,我老是不记得去用 case when,一直习惯 ...
原帖由 rardge 于 2006-3-7 15:01 发表
select classid, count(case when mark > 60 then 1 end) as m, count(case when fen > 70 then 1 end) as f from tbname group by classid
受 Namelessxp 启发而写,我老是不记得去用 case when,一直习惯 ...
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |