利用coalesce()搭配group方法使用
select
name,
max(case when subject='数学' then source end 0) math,
max(case when subject='语文' then source end 0) chinese,
max(case when subject='英语' then source end 0) english,
from t1
group name
利用coalesce()搭配group方法使用
select
name,
max(case when subject='数学' then source end 0) math,
max(case when subject='语文' then source end 0) chinese,
max(case when subject='英语' then source end 0) english,
from t1
group name