ソースコード

select
      a.PORT_CODE as "港コード"
    , PORT.PORT_NAME as "港名"
    , a.immigration as "入国者数"
    , a.departure as "出国者数"
    , a.diff as "差分"
from
    (
    select
          PORT_CODE
        , immigration
        , departure
        , immigration - departure as diff
    from
        (
        select
              PORT_CODE
            , max(case when KIND_CODE = 110 then AMT end) as immigration
            , max(case when KIND_CODE = 120 then AMT end) as departure
        from
            (
            select
                  PORT_CODE
                , KIND_CODE
                , sum(AMT) as AMT
            from
                IMMIGRATION
            where
                GROUP_CODE = 120
            group by PORT_CODE, KIND_CODE
            )
        group by PORT_CODE
        )
    where
        immigration > departure
    ) a
    left outer join PORT using(PORT_CODE)
order by
    a.diff desc, a.PORT_CODE asc
提出情報
提出日時2022/07/20 21:09:27
コンテスト第1回 SQLコンテスト
問題港入出国者分析
受験者NoRa
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量101 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
WA
99 MB
データパターン2
AC
101 MB