ソースコード
SELECT 
PP '港コード',
PN  '港名',
X '入国者数',
Y '出国者数',
S '差分'
FROM(
SELECT DISTINCT
IM.PORT_CODE PP,
PORT.PORT_NAME  PN,
XXX.X3 X,
YYY.Y3 Y,
XXX.X3 - YYY.Y3 S
FROM 
IMMIGRATION IM,
GRP,
PORT,
(SELECT DISTINCT IMMIGRATION.PORT_CODE X1, IMMIGRATION.GROUP_CODE X2, AMT AS X3 FROM IMMIGRATION, GRP,PORT WHERE IMMIGRATION.PORT_CODE = PORT.PORT_CODE AND IMMIGRATION.GROUP_CODE = GRP.GROUP_CODE AND IMMIGRATION.KIND_CODE = '110' AND IMMIGRATION.GROUP_CODE = '120') XXX,
(SELECT DISTINCT IMMIGRATION.PORT_CODE Y1, IMMIGRATION.GROUP_CODE Y2, AMT AS Y3 FROM IMMIGRATION, GRP,PORT WHERE IMMIGRATION.PORT_CODE = PORT.PORT_CODE AND IMMIGRATION.GROUP_CODE = GRP.GROUP_CODE AND IMMIGRATION.KIND_CODE = '120' AND IMMIGRATION.GROUP_CODE = '120') YYY
WHERE 
IM.PORT_CODE = PORT.PORT_CODE AND
IM.PORT_CODE = XXX.X1 AND
IM.PORT_CODE = YYY.Y1 AND
IM.GROUP_CODE = GRP.GROUP_CODE AND 
IM.GROUP_CODE = XXX.X2 AND 
IM.GROUP_CODE = YYY.Y2

)
WHERE S > 0
ORDER BY  S DESC, PP DESC
提出情報
提出日時2022/12/06 11:10:43
コンテスト第1回 SQLコンテスト
問題港入出国者分析
受験者nasu
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量81 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
80 MB
データパターン2
AC
81 MB