ソースコード
SELECT A_PORT_CODE AS "港コード", PORT_NAME AS "港名", AMT110 AS 入国者数, AMT120 AS 出国者数, (AMT110 - AMT120) as 差分 FROM (
    SELECT PORT_CODE AS A_PORT_CODE, AMT as "AMT110" FROM IMMIGRATION
        INNER JOIN GRP ON IMMIGRATION.GROUP_CODE = GRP.GROUP_CODE
        WHERE KIND_CODE = 110 AND GROUP_NAME = "外国人"
    )
    INNER JOIN (
        SELECT PORT_CODE AS B_PORT_CODE, AMT as "AMT120" FROM IMMIGRATION
        INNER JOIN GRP ON IMMIGRATION.GROUP_CODE = GRP.GROUP_CODE
        WHERE KIND_CODE = 120 AND GROUP_NAME = "外国人"
    ) ON A_PORT_CODE = B_PORT_CODE
    INNER JOIN PORT ON A_PORT_CODE = PORT.PORT_CODE
    WHERE 差分 > 0
    ORDER BY 差分 DESC, A_PORT_CODE DESC
            
提出情報
提出日時2022/07/20 21:44:22
コンテスト第1回 SQLコンテスト
問題港入出国者分析
受験者spica314
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量103 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
103 MB
データパターン2
AC
56 MB