日期:2014-05-18 浏览次数:20548 次
select name 姓名, max(case subject when '语文' then grade else 0 end) 语文, max(case subject when '数学' then grade else 0 end) 数学, max(case subject when '英语' then grade else 0 end) 英语 from grades group by name
select top 3 * from grades where exists( select name 姓名, max(case subject when '语文' then grade else 0 end) 语文, max(case subject when '数学' then grade else 0 end) 数学, max(case subject when '英语' then grade else 0 end) 英语 from grades group by name )
select top 3 * from (select name 姓名, max(case subject when '语文' then grade else 0 end) 语文, max(case subject when '数学' then grade else 0 end) 数学, max(case subject when '英语' then grade else 0 end) 英语 from grades group by name )t