\--试题一\
select name,
max(case subject when '语文' then Result end) as 语文,
max(case subject when '数学' then Result end) as 数学,
max(case subject when '物理' then Result end) as 物理,
cast(avg(Result) as decimal(18,2) 平均分,
sum(Result) as 总分
group by name
\--试题三\
select name,
max(case subject when '语文' then Result end) as 语文,
max(case subject when '数学' then Result end) as 数学,
max(case subject when '物理' then Result end) as 物理,
cast(avg(Result) as decimal(18,2) 平均分,
group by name