select a.name as name , (select source from test where name = a.name and subject = 'k1') as 语文 , (select source from test where name = a.name and subject = 'k2') as 数学 , (select source from test where name = a.name and subject = 'k3') as 英语 , (select count(source) from test where name = a.name and source<60) as 不及格 from test a group by a.name union select ' as name , (select count(source) from test where subject = 'k1' and source<60) as 语文 , (select count(source) from test where subject = 'k2' and source<60) as 数学 , (select count(source) from test where subject = 'k3' and source<60) as 英语 , (select count(source) from test where source<60) as 不及格 from test group by a.name order by a.name