ソースコード
SELECT 
       T1.PC AS '港コード'
       ,PT.PORT_NAME AS '港名'
       ,T1.NKSS AS '入国者数'
       ,T1.SKSS AS '出国者数'
       ,T1.SB AS '差分'
FROM 
    (SELECT
       IM.PORT_CODE AS PC
       ,SUM(CASE WHEN IM.GROUP_CODE = '120' AND IM.KIND_CODE = '110' THEN AMT ELSE '0' END) AS NKSS
       ,SUM(CASE WHEN IM.GROUP_CODE = '120' AND IM.KIND_CODE = '120' THEN AMT ELSE '0' END) AS SKSS
       ,SUM(CASE WHEN IM.GROUP_CODE = '120' AND IM.KIND_CODE = '110' THEN AMT ELSE '0' END) 
        - 
        SUM(CASE WHEN IM.GROUP_CODE = '120' AND IM.KIND_CODE = '120' THEN AMT ELSE '0' END) 
         AS SB
    FROM
        IMMIGRATION AS IM
    GROUP BY
      IM.PORT_CODE) T1
INNER JOIN
    PORT AS PT
ON
    PT.PORT_CODE = T1.PC
    
WHERE SB > 0
ORDER BY
    T1.SB DESC
    ,T1.PC DESC
提出情報
提出日時2024/06/04 13:41:15
コンテスト第1回 SQLコンテスト
問題港入出国者分析
受験者512441
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量90 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
90 MB
データパターン2
AC
85 MB