ソースコード
select
a.PORT_CODE AS 港コード,
c.PORT_NAME AS 港名,

sum(a.AMT) as 入国者数 , 
sum(b.AMT) as 出国者数,
sum(a.AMT) - sum(b.AMT) as 差分
from 
IMMIGRATION a 
left join  IMMIGRATION b on a.port_code=b.port_code
and a.kind_code='110' and b.kind_code='120'
left join PORT c on a.port_code=c.port_code
left join grp g on a.group_code=g.group_code
where a.group_code='120' and b.group_code='120'

group by a.port_code
having sum(a.AMT) - sum(b.AMT) >0
order by 差分 desc ,港コード desc 
提出情報
提出日時2022/07/20 19:12:45
コンテスト第1回 SQLコンテスト
問題港入出国者分析
受験者noneof383
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量102 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
100 MB
データパターン2
AC
102 MB