日期:2014-05-17 浏览次数:20752 次
id 学员号(xyh) 考试次数(kscs) 结果(cj) 座位号(zwh)
1 A001 1 不及格 001
2 A001 2 及格 001
3 A002 1 及格 002
4 A003 1 不及格 001
5 A003 2 及格 001
select count(distinct case when kscs = 1 and cj = '及格' then xyh
when kscs = 2 and cj = '及格' then xyh else then null end) as 及格人数,
count(distinct case when kscs = 2 and cj = '不及格' then xyh else then null end) as 不及格人数,
count(distinct xyh) as 总人数
from tb_name
select sum(decode(cj,'及格',1,0)) 及格数,sum(decode(cj,'及格',0,1)) 不及格数,count(1) 总数 from (select max(cj) cj from t group by xyh);
select sum(cj) pass,count(1)-sum(cj) delay from
(select sum(decode(cj,'及格',1,0)) cj from tb group by xyh)
select count(distinct case when kscs = 1 and cj = '及格' then xyh
when kscs = 2 and cj = '及格' then xyh else null end) as 及格人数,
count(distinct case when kscs = 2 and cj = '不及格' then xyh)&n