ソースコード
SELECT port.port_code AS "港コード",
       port.port_name AS "港名",
       sum(CASE
               WHEN immigration.kind_code = "110" THEN immigration.amt
               ELSE 0
           END) AS "入国者数",
       sum(CASE
               WHEN immigration.kind_code = "120" THEN immigration.amt
               ELSE 0
           END) AS "出国者数",
       sum(CASE
               WHEN immigration.kind_code = "110" THEN immigration.amt
               WHEN immigration.kind_code = "120" THEN -immigration.amt
               ELSE 0
           END) AS "差分"
FROM port
JOIN immigration ON port.port_code = immigration.port_code
WHERE immigration.group_code = "120"
GROUP BY port.port_code
HAVING "入国者数" > "出国者数"
ORDER BY "差分" DESC,
         "港コード" DESC
提出情報
提出日時2022/07/20 18:25:51
コンテスト第1回 SQLコンテスト
問題港入出国者分析
受験者tadataka
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量105 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
97 MB
データパターン2
AC
105 MB