読者です 読者をやめる 読者になる 読者になる

メモメモ

select
名前,
sum(case when 月=1 then 金額 else 0 end) as 1月,
sum(case when 月=2 then 金額 else 0 end) as 2月,
sum(case when 月=3 then 金額 else 0 end) as 3月,
sum(case when 月=4 then 金額 else 0 end) as 4月,
sum(case when 月=5 then 金額 else 0 end) as 5月,
sum(case when 月=6 then 金額 else 0 end) as 6月,
sum(case when 月=7 then 金額 else 0 end) as 7月,
sum(case when 月=8 then 金額 else 0 end) as 8月,
sum(case when 月=9 then 金額 else 0 end) as 9月,
sum(case when 月=10 then 金額 else 0 end) as 10月,
sum(case when 月=11 then 金額 else 0 end) as 11月,
sum(case when 月=12 then 金額 else 0 end) as 12月
from テーブル名
group by 名前