コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
SELECT
IMMIGRATION.PORT_CODE AS 港コード,
PORT.PORT_NAME AS 港名,
( SUM(CASE WHEN IMMIGRATION.KIND_CODE = '110' THEN IMMIGRATION.AMT ELSE 0 END) - SUM(CASE WHEN IMMIGRATION.KIND_CODE = '110' AND IMMIGRATION.GROUP_CODE = '110' THEN IMMIGRATION.AMT ELSE 0 END) - SUM(CASE WHEN IMMIGRATION.KIND_CODE = '110' AND IMMIGRATION.GROUP_CODE = '130' THEN IMMIGRATION.AMT ELSE 0 END)) AS 入国者数,
( SUM(CASE WHEN IMMIGRATION.KIND_CODE = '120' THEN IMMIGRATION.AMT ELSE 0 END) - SUM(CASE WHEN IMMIGRATION.KIND_CODE = '120' AND IMMIGRATION.GROUP_CODE = '110' THEN IMMIGRATION.AMT ELSE 0 END) - SUM(CASE WHEN IMMIGRATION.KIND_CODE = '120' AND IMMIGRATION.GROUP_CODE = '130' 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 = '110' AND IMMIGRATION.GROUP_CODE = '110' THEN IMMIGRATION.AMT ELSE 0 END) - SUM(CASE WHEN IMMIGRATION.KIND_CODE = '110' AND IMMIGRATION.GROUP_CODE = '130' THEN IMMIGRATION.AMT ELSE 0 END))
- ( SUM(CASE WHEN IMMIGRATION.KIND_CODE = '120' THEN IMMIGRATION.AMT ELSE 0 END) - SUM(CASE WHEN IMMIGRATION.KIND_CODE = '120' AND IMMIGRATION.GROUP_CODE = '110' THEN IMMIGRATION.AMT ELSE 0 END) - SUM(CASE WHEN IMMIGRATION.KIND_CODE = '120' AND IMMIGRATION.GROUP_CODE = '130' THEN IMMIGRATION.AMT ELSE 0 END)) AS 差分
FROM IMMIGRATION INNER JOIN PORT ON IMMIGRATION.PORT_CODE = PORT.PORT_CODE
GROUP BY IMMIGRATION.PORT_CODE
--HAVING (( SUM(CASE WHEN IMMIGRATION.KIND_CODE = '110' THEN IMMIGRATION.AMT ELSE 0 END) - SUM(CASE WHEN IMMIGRATION.GROUP_CODE = '110' THEN IMMIGRATION.AMT ELSE 0 END)) - ( SUM(CASE WHEN IMMIGRATION.KIND_CODE = '120' THEN IMMIGRATION.AMT ELSE 0 END) - SUM(CASE WHEN IMMIGRATION.GROUP_CODE = '110' THEN IMMIGRATION.AMT ELSE 0 END))) > 0
HAVING 差分 > 0
ORDER BY 差分 DESC, IMMIGRATION.PORT_CODE DESC;
提出情報
提出日時 | 2022/07/20 19:21:00 |
コンテスト | 第1回 SQLコンテスト |
問題 | 港入出国者分析 |
受験者 | rs_201504_sk |
状態 (詳細) | AC (Accepted: 正答) |
メモリ使用量 | 100 MB |
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
100 MB
データパターン2
AC
85 MB