ソースコード
SELECT PORT.PORT_CODE AS '港コード', 
        PORT.PORT_NAME AS '港名',
        SUM(CASE WHEN IMMIGRATION.KIND_CODE = 110 THEN IMMIGRATION.AMT ELSE NULL END) AS '入国者数',
        SUM(CASE WHEN IMMIGRATION.KIND_CODE = 120 THEN IMMIGRATION.AMT ELSE NULL END) AS '出国者数',
        SUM(CASE WHEN IMMIGRATION.KIND_CODE = 110 THEN IMMIGRATION.AMT ELSE NULL END) - SUM(CASE WHEN IMMIGRATION.KIND_CODE = 120 THEN IMMIGRATION.AMT ELSE NULL END) AS '差分'
        FROM PORT 
        INNER JOIN IMMIGRATION ON PORT.PORT_CODE = IMMIGRATION.PORT_CODE
        INNER JOIN GRP ON IMMIGRATION.GROUP_CODE = GRP.GROUP_CODE
        GROUP BY PORT.PORT_CODE
        HAVING SUM(CASE WHEN IMMIGRATION.KIND_CODE = 110 THEN IMMIGRATION.AMT ELSE NULL END) > SUM(CASE WHEN IMMIGRATION.KIND_CODE = 120 THEN IMMIGRATION.AMT ELSE NULL END)
        ORDER BY SUM(CASE WHEN IMMIGRATION.KIND_CODE = 120 THEN IMMIGRATION.AMT ELSE NULL END) - SUM(CASE WHEN IMMIGRATION.KIND_CODE = 110 THEN IMMIGRATION.AMT ELSE NULL END) ASC,
                    PORT.PORT_CODE ASC
提出情報
提出日時2022/07/20 21:52:53
コンテスト第1回 SQLコンテスト
問題港入出国者分析
受験者kiyosan
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量103 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
WA
103 MB
データパターン2
AC
89 MB