コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
with BASE as(
select
A.SURVEY_YEAR as SV_YEAR
, A.PF_CODE
, B.PF_NAME as PREFECTURE
, SUM(A.ELEMENTARY) as ELEMENTARY
, SUM(A.MIDDLE) as MIDDLE
, SUM(A.HIGH) as HIGH
, SUM(A.JUNIOR_CLG) as JUNIOR_CLG
, SUM(A.COLLEGE) as COLLEGE
, SUM(A.GRADUATE) as GRADUATE
from
ENROLLMENT_STATUS A
, PREFECTURE B
where
A.PF_CODE = B.PF_CODE
and A.SURVEY_YEAR = '2020'
group by
SV_YEAR
, A.PF_CODE
, PREFECTURE
),
BASE2 as(
select
SV_YEAR
, PF_CODE
, PREFECTURE
, '小学校' AS KIND
, '1' as NUM
, ELEMENTARY as AMT
from
BASE
where
ELEMENTARY IS NOT NULL
union
select
SV_YEAR
, PF_CODE
, PREFECTURE
, '中学校' AS KIND
, '2' as NUM
, MIDDLE as AMT
from
BASE
where
MIDDLE IS NOT NULL
union
select
SV_YEAR
, PF_CODE
, PREFECTURE
, '高校' AS KIND
, '3' as NUM
, HIGH as AMT
from
BASE
where
HIGH IS NOT NULL
union
select
SV_YEAR
, PF_CODE
, PREFECTURE
, '短大' AS KIND
, '4' as NUM
, JUNIOR_CLG as AMT
from
BASE
where
JUNIOR_CLG IS NOT NULL
union
select
SV_YEAR
, PF_CODE
, PREFECTURE
, '大学' AS KIND
, '5' as NUM
, COLLEGE as AMT
from
BASE
where
COLLEGE IS NOT NULL
union
select
SV_YEAR
, PF_CODE
, PREFECTURE
, '大学院' AS KIND
, '6' as NUM
, GRADUATE as AMT
from
BASE
where
GRADUATE IS NOT NULL
)
SELECT
SV_YEAR
, PREFECTURE
, KIND
, AMT
from
BASE2
order by
PF_CODE
, NUM
提出情報
提出日時 | 2022/09/21 21:23:20 |
コンテスト | 第2回 SQLコンテスト |
問題 | 就学状況の表示変換 |
受験者 | r1000000 |
状態 (詳細) | AC (Accepted: 正答) |
メモリ使用量 | 103 MB |
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
100 MB
データパターン2
AC
103 MB