ソースコード
with A as 
  (select  IMMIGRATION.PORT_CODE as PORT_CODE, PORT.PORT_NAME as PORT_NAME,AMT as AMT_IN
from IMMIGRATION
inner join GRP on IMMIGRATION.GROUP_CODE = GRP.GROUP_CODE
inner join PORT on IMMIGRATION.PORT_CODE = PORT.PORT_CODE
where IMMIGRATION.KIND_CODE = 110 and GRP.GROUP_NAME = "外国人"),

B as 
  (select  IMMIGRATION.PORT_CODE as PORT_CODE, PORT.PORT_NAME as PORT_NAME,AMT as AMT_OUT
from IMMIGRATION
inner join GRP on IMMIGRATION.GROUP_CODE = GRP.GROUP_CODE
inner join PORT on IMMIGRATION.PORT_CODE = PORT.PORT_CODE
where IMMIGRATION.KIND_CODE = 120 and GRP.GROUP_NAME = "外国人")

select A.PORT_CODE as "港コード",
    A.PORT_NAME as "港名",
    A.AMT_IN as "入国者数",
    B.AMT_OUT as "出国者数",
    A.AMT_IN-B.AMT_OUT as "差分"
FROM A
left join B on A.PORT_CODE = B.PORT_CODE
where A.AMT_IN >B.AMT_OUT
ORDER BY "差分" DESC,"港コード" DESC
提出情報
提出日時2022/08/31 14:01:45
コンテスト第1回 SQLコンテスト
問題港入出国者分析
受験者k951286
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量82 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
82 MB
データパターン2
AC
77 MB