ソースコード
SELECT
  PRT.PORT_CODE AS '港コード',
  PRT.PORT_NAME AS '港名',
  N_IN AS '入国者数',
  N_OUT AS '出国者数',
  N_IN - N_OUT AS '差分'
FROM PORT AS PRT
JOIN (
  SELECT
      PORT_CODE,
      SUM(AMT) AS 'N_IN'
  FROM IMMIGRATION
  WHERE KIND_CODE = 110 AND GROUP_CODE = 120
  GROUP BY PORT_CODE
) AS STATS_IN
ON PRT.PORT_CODE = STATS_IN.PORT_CODE
JOIN (
  SELECT
      PORT_CODE,
      SUM(AMT) AS 'N_OUT'
  FROM IMMIGRATION
  WHERE KIND_CODE = 120 AND GROUP_CODE = 120
  GROUP BY PORT_CODE
) AS STATS_OUT
ON PRT.PORT_CODE = STATS_OUT.PORT_CODE
WHERE N_IN > N_OUT
ORDER BY N_IN - N_OUT DESC, PRT.PORT_CODE DESC
;
提出情報
提出日時2022/07/20 20:32:16
コンテスト第1回 SQLコンテスト
問題港入出国者分析
受験者YohKmb
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量103 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
103 MB
データパターン2
AC
101 MB