ソースコード
SELECT
    IMMIGRATION.PORT_CODE,
    PORT.PORT_NAME,
    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 ELSE 0 END)
    - SUM(
        CASE WHEN IMMIGRATION.KIND_CODE = '120' THEN IMMIGRATION.AMT ELSE 0 END
    ) AS "差分"
FROM IMMIGRATION
INNER JOIN PORT ON IMMIGRATION.PORT_CODE = PORT.PORT_CODE
WHERE IMMIGRATION.GROUP_CODE = '120'
GROUP BY IMMIGRATION.PORT_CODE
HAVING
    SUM(CASE WHEN IMMIGRATION.KIND_CODE = '110' THEN IMMIGRATION.AMT ELSE 0 END)
    > SUM(
        CASE WHEN IMMIGRATION.KIND_CODE = '120' THEN IMMIGRATION.AMT ELSE 0 END
    )
ORDER BY "差分" DESC, IMMIGRATION.PORT_CODE DESC;

提出情報
提出日時2024/06/02 22:44:42
コンテスト第1回 SQLコンテスト
問題港入出国者分析
受験者hatarino
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
85 MB
データパターン2
WA
85 MB