日期:2014-05-18 浏览次数:20454 次
select name as 姓名 ,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 6 * from grades where name not in (select top 0 name from grades order by name) order by name
SELECT name,语文,数学,英语 FROM t1 PIVOT ( MAX(grade) FOR subject IN (语文,数学,英语) )p