ソースコード
select
  table_in.PORT_CODE as 港コード,
  PORT.PORT_NAME as 港名,
  table_in.AMT as 入国者数,
  table_out.AMT as 出国者数,
  table_in.AMT - table_out.AMT as 差分
from
( 
  select
    i.PORT_CODE as PORT_CODE,
    SUM(i.AMT) as AMT
  from
    IMMIGRATION as i
  join
    GRP as g
  on
    i.GROUP_CODE = g.GROUP_CODE
  where
    g.GROUP_NAME = "外国人" and
    i.KIND_CODE = "110"
  group by
    i.PORT_CODE
) as table_in
join
(
  select
    i.PORT_CODE as PORT_CODE,
    SUM(i.AMT) as AMT
  from
    IMMIGRATION as i
  join
    GRP as g
  on
    i.GROUP_CODE = g.GROUP_CODE
  where
    g.GROUP_NAME = "外国人" and
    i.KIND_CODE = "120"
  group by
    i.PORT_CODE
) as table_out
on 
  table_in.PORT_CODE = table_out.PORT_CODE
join
  PORT
on
  table_in.PORT_CODE = PORT.PORT_CODE
where
  table_in.AMT > table_out.AMT
order by
  差分 desc
;
提出情報
提出日時2022/07/20 21:18:49
コンテスト第1回 SQLコンテスト
問題港入出国者分析
受験者vesper
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量103 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
WA
103 MB
データパターン2
AC
32 MB