利用max(case when then)
表结构:
select name as 姓名,
max(
case
when subject='语文' then score
end
) as '语文',
max(
case
when subject='数学' then score
end
) as '数学'
from student group by name;
利用max(case when then)
表结构:
select name as 姓名,
max(
case
when subject='语文' then score
end
) as '语文',
max(
case
when subject='数学' then score
end
) as '数学'
from student group by name;