ソースコード
select 
 p.port_code as `港コード`,
 p.port_name as `港名`,
 sum(case when i.kind_code='110' then amt else 0 end) as `入国者数`,
 sum(case when i.kind_code='120' then amt else 0 end) as `出国者数`,
 sum(case when i.kind_code='110' then amt else 0 end)
  - sum(case when i.kind_code='120' then amt else 0 end) as `差分`
from
 immigration as i
inner join
 port as p
on
 p.port_code=i.port_code
inner join
 grp as g
on
 i.group_code=g.group_code
 and g.group_name='外国人'
group by
 1,2
having
  sum(case when i.kind_code='110' then amt else 0 end)
  - sum(case when i.kind_code='120' then amt else 0 end) > 0
order by
 5 desc, 1 desc
提出情報
提出日時2022/07/20 17:50:18
コンテスト第1回 SQLコンテスト
問題港入出国者分析
受験者nyangao
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量104 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
104 MB
データパターン2
AC
98 MB