コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
with tmp as (
select
SURVEY_YEAR
,PF_CODE
, '小学校' as KIND
, ELEMENTARY AS AMT
, 1 as rn
from
ENROLLMENT_STATUS
where
SURVEY_YEAR = 2020
and ELEMENTARY > 0
and ELEMENTARY is not null
UNION ALL
select
SURVEY_YEAR
,PF_CODE
, '中学校' as KIND
, MIDDLE AS AMT
, 2 as rn
from
ENROLLMENT_STATUS
where
SURVEY_YEAR = 2020
and MIDDLE > 0
and MIDDLE is not null
UNION ALL
select
SURVEY_YEAR
,PF_CODE
, '高校' as KIND
, HIGH AS AMT
, 3 as rn
from
ENROLLMENT_STATUS
where
SURVEY_YEAR = 2020
and HIGH > 0
and HIGH is not null
UNION ALL
select
SURVEY_YEAR
,PF_CODE
, '短大' as KIND
, JUNIOR_CLG AS AMT
, 4 as rn
from
ENROLLMENT_STATUS
where
SURVEY_YEAR = 2020
and JUNIOR_CLG > 0
and JUNIOR_CLG is not null
UNION ALL
select
SURVEY_YEAR
,PF_CODE
, '大学' as KIND
, COLLEGE AS AMT
, 5 as rn
from
ENROLLMENT_STATUS
where
SURVEY_YEAR = 2020
and COLLEGE > 0
and COLLEGE is not null
UNION ALL
select
SURVEY_YEAR
,PF_CODE
, '大学院' as KIND
, GRADUATE AS AMT
, 6 as rn
from
ENROLLMENT_STATUS
where
SURVEY_YEAR = 2020
and GRADUATE > 0
and GRADUATE is not null
), t as (
select
e.SURVEY_YEAR as SV_YEAR
,e.PF_CODE
,p.PF_NAME as PREFECTURE
,e.KIND as KIND
,e.rn
,sum(AMT) as AMT
from
tmp as e
inner join PREFECTURE as p
on e.PF_CODE = p.PF_CODE
group by SURVEY_YEAR,PF_NAME,KIND,e.rn
)
select
SV_YEAR
,PREFECTURE
,KIND
,AMT
from t
order by PF_CODE asc, rn asc
提出情報
提出日時 | 2023/07/05 17:17:59 |
コンテスト | 第2回 SQLコンテスト |
問題 | 就学状況の表示変換 |
受験者 | mywk |
状態 (詳細) | WA (Wrong Answer: 誤答) |
メモリ使用量 | 80 MB |
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
WA
79 MB
データパターン2
AC
80 MB