ソースコード
WITH temp AS(
    SELECT 
        PORT_CODE,
    SUM(
    CASE 
        WHEN
            KIND_CODE = 110
        THEN
            AMT
        ELSE
            0
        END
    ) AS import,
     SUM(
    CASE 
        WHEN
            KIND_CODE = 120
        THEN
            AMT
        ELSE
            0
        END
    ) AS export
    FROM
        IMMIGRATION
    GROUP BY 
    PORT_CODE
),
temp2 AS
(SELECT
    *,
    import - export AS diff
FROM
    temp

)
SELECT
    t1.PORT_CODE AS "港コード",
    port_name AS "港名",
    import AS "入国者数",
    export  AS "出国者数",
    diff AS "差分"
FROM
    temp2 AS t1
JOIN
 PORT    AS t2

ON
    t1.port_code = t2.port_code
    AND
    diff > 0
ORDER BY
    diff desc,
    t1.port_code desc
    
提出情報
提出日時2022/07/20 18:36:02
コンテスト第1回 SQLコンテスト
問題港入出国者分析
受験者lilium
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量105 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
WA
88 MB
データパターン2
AC
105 MB