コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
WITH t AS (
SELECT
*
FROM
ENROLLMENT_STATUS
LEFT JOIN PREFECTURE USING(PF_CODE)
WHERE
SURVEY_YEAR = 2020
)
SELECT
SURVEY_YEAR AS SV_YEAR,
PF_NAME AS PREFECTURE,
KIND,
SUM(AMT) AS AMT
FROM
(
SELECT
survey_year,
PF_CODE,
PF_NAME,
"小学校" AS KIND,
ELEMENTARY AS AMT,
1 AS school_order
FROM
t
UNION
ALL
SELECT
survey_year,
PF_CODE,
PF_NAME,
"中学校" AS KIND,
MIDDLE AS AMT,
2 AS school_order
FROM
t
UNION
ALL
SELECT
survey_year,
PF_CODE,
PF_NAME,
"高校" AS KIND,
HIGH AS AMT,
3 AS school_order
FROM
t
UNION
ALL
SELECT
survey_year,
PF_CODE,
PF_NAME,
"短大" AS KIND,
JUNIOR_CLG AS AMT,
4 AS school_order
FROM
t
UNION
ALL
SELECT
survey_year,
PF_CODE,
PF_NAME,
"大学" AS KIND,
COLLEGE AS AMT,
5 AS school_order
FROM
t
UNION
ALL
SELECT
survey_year,
PF_CODE,
PF_NAME,
"大学院" AS KIND,
GRADUATE AS AMT,
6 AS school_order
FROM
t
)
WHERE AMT IS NOT NULL
GROUP BY
SURVEY_YEAR,
PF_NAME,
KIND
ORDER BY
PF_CODE,
school_order
提出情報
提出日時 | 2022/09/22 00:09:36 |
コンテスト | 第2回 SQLコンテスト |
問題 | 就学状況の表示変換 |
受験者 | ogatango |
状態 (詳細) | AC (Accepted: 正答) |
メモリ使用量 | 94 MB |
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
94 MB
データパターン2
AC
83 MB