コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
with tmp as(
select "FOREIGNER"."PF_CODE","PREFECTURE"."PF_NAME","NATIONALITY"."NATION_NAME","FOREIGNER"."AMT",RANK() over (partition by "FOREIGNER"."PF_CODE" order by "FOREIGNER"."AMT" desc) as "rank" from "FOREIGNER"
inner join "NATIONALITY" on "NATIONALITY"."NATION_CODE" = "FOREIGNER"."NATION_CODE" inner join "PREFECTURE" on "PREFECTURE"."PF_CODE" = "FOREIGNER"."PF_CODE" where "NATIONALITY"."NATION_CODE" <> '113'
)
select distinct
tmp."PF_CODE" as "都道府県コード",
tmp."PF_NAME" as "都道府県名",
(select tmp1."NATION_NAME" from (select * from tmp) as tmp1 where tmp1."PF_CODE" = tmp."PF_CODE" and tmp1."rank" = 1) as "1位 国名",
(select tmp1."AMT" from (select * from tmp) as tmp1 where tmp1."PF_CODE" = tmp."PF_CODE" and tmp1."rank" = 1) as "1位 人数",
(select tmp1."NATION_NAME" from (select * from tmp) as tmp1 where tmp1."PF_CODE" = tmp."PF_CODE" and tmp1."rank" = 2) as "2位 国名",
(select tmp1."AMT" from (select * from tmp) as tmp1 where tmp1."PF_CODE" = tmp."PF_CODE" and tmp1."rank" = 2) as "2位 人数",
(select tmp1."NATION_NAME" from (select * from tmp) as tmp1 where tmp1."PF_CODE" = tmp."PF_CODE" and tmp1."rank" = 3) as "3位 国名",
(select tmp1."AMT" from (select * from tmp) as tmp1 where tmp1."PF_CODE" = tmp."PF_CODE" and tmp1."rank" = 3) as "3位 人数",
(select sum("FOREIGNER"."AMT") from "FOREIGNER" where "FOREIGNER"."PF_CODE" = tmp."PF_CODE" and "FOREIGNER"."NATION_CODE" <> '113') as "合計人数"
from tmp order by "合計人数" desc, "都道府県コード" desc
提出情報
提出日時 | 2022/11/25 16:53:37 |
コンテスト | 第1回 SQLコンテスト |
問題 | 外国籍分布 |
受験者 | hhxu |
状態 (詳細) | WA (Wrong Answer: 誤答) |
メモリ使用量 | 81 MB |
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
WA
81 MB
データパターン2
AC
78 MB