展开全部
\--试题一\
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询