ソースコード

with tmp as (
	SELECT
	IMT.PORT_CODE
	, PORT.PORT_NAME
	, sum(case when GRP.GROUP_CODE = '120' and IMT.KIND_CODE = '110' then IMT.AMT else 0 end) as total_in
	, sum(case when GRP.GROUP_CODE = '120' and IMT.KIND_CODE = '120' then IMT.AMT else 0 end) as total_out
	FROM IMMIGRATION as IMT
		INNER JOIN GRP ON IMT.GROUP_CODE = GRP.GROUP_CODE AND GRP.GROUP_CODE = '120'
		INNER JOIN PORT ON IMT.PORT_CODE = PORT.PORT_CODE
	WHERE IMT.KIND_CODE in ('110', '120')
	GROUP BY 1,2
)
SELECT
	t1.PORT_CODE as '港コード'
	, t1.PORT_NAME as '港名'
	, t1.total_in as '入国者数'
	, t1.total_out as '出国者数'
	, t1.total_in - t1.total_out as '差分'
FROM tmp as t1
WHERE t1.total_in > t1.total_out
ORDER BY 5 desc, 1
;
提出情報
提出日時2022/07/23 12:41:13
コンテスト第1回 SQLコンテスト
問題港入出国者分析
受験者naichi51
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量83 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
WA
83 MB
データパターン2
AC
77 MB