ソースコード
select
    a.port_code as "港コード",
    b.port_name as "港名",
    sum(case when a.kind_code = 110 then amt else 0 end) as "入国者数",
    sum(case when a.kind_code = 120 then amt else 0 end) as "出国者数",
    sum(case when a.kind_code = 110 then amt else 0 end) - sum(case when a.kind_code = 120 then amt else 0 end) as "差分"
from IMMIGRATION as a
inner join port as b
using(port_code)
where a.group_code = 120 and a.kind_code in (110, 120)
group by a.port_code, b.port_name
having sum(case when a.kind_code = 110 then amt else 0 end) - sum(case when a.kind_code = 120 then amt else 0 end) > 0
order by sum(case when a.kind_code = 110 then amt else 0 end) - sum(case when a.kind_code = 120 then amt else 0 end) desc, a.port_code desc
提出情報
提出日時2022/12/05 22:43:33
コンテスト第1回 SQLコンテスト
問題港入出国者分析
受験者miotsukushi0800
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量80 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
80 MB
データパターン2
AC
76 MB