select d.性别, b.及格, c.不及格 from (select distinct 性别 from a) d, (select 性别, count(1) as 及格 from a where 成绩 >= 60 group by 性别) b, (select 性别, count(1) as 不及格 from a where 成绩 < 60 group by 性别) c where d.性别 = b.性别 and d.性别 = c.性别
select 性别,sum(yes) as 及格,sum(no) as 不及格 from ( select 性别,yes=case when 成绩>=60 then 1 else 0 end, no=case when 成绩<60 then 1 else 0 end from 表1 ) as temp group by 性别
select a.sex,b.及格,c.不及格 from (select sex from t_test group by sex ) as a , (select sex ,count(1)as 及格 from t_test where result>=60 group by sex ) as b, (select sex,count(1) as 不及格 from t_test where result<60 group by sex) as c where a.sex=b.sex and a.sex=c.sex