コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
select
SV_YEAR,
PREFECTURE,
KIND,
AMT
from
(SELECT
SURVEY_YEAR as 'SV_YEAR',
PF_NAME as 'PREFECTURE',
'小学校' as 'KIND',
0 as 'NO',
p,
ELEMENTARY as 'AMT'
FROM
(SELECT
SURVEY_YEAR,
PF_NAME,
SUM(ELEMENTARY) AS 'ELEMENTARY',
ES.PF_CODE as p
FROM
ENROLLMENT_STATUS ES
LEFT JOIN
PREFECTURE PRF
ON ES.PF_CODE = PRF.PF_CODE
WHERE
SURVEY_YEAR = 2020
GROUP BY
SURVEY_YEAR,
PF_NAME
) BASE
WHERE AMT is not null
UNION ALL
SELECT
SURVEY_YEAR as 'SV_YEAR',
PF_NAME as 'PREFECTURE',
'中学校' as 'KIND',
1 as 'NO',
p,
MIDDLE as 'AMT'
FROM
(SELECT
SURVEY_YEAR,
PF_NAME,
SUM(MIDDLE) AS 'MIDDLE',
ES.PF_CODE as p
FROM
ENROLLMENT_STATUS ES
LEFT JOIN
PREFECTURE PRF
ON ES.PF_CODE = PRF.PF_CODE
WHERE
SURVEY_YEAR = 2020
GROUP BY
SURVEY_YEAR,
PF_NAME
) BASE
WHERE AMT is not null
UNION ALL
SELECT
SURVEY_YEAR as 'SV_YEAR',
PF_NAME as 'PREFECTURE',
'高校' as 'KIND',
2 as 'NO',
p,
HIGH as 'AMT'
FROM
(SELECT
SURVEY_YEAR,
PF_NAME,
SUM(HIGH) as 'HIGH',
ES.PF_CODE as p
FROM
ENROLLMENT_STATUS ES
LEFT JOIN
PREFECTURE PRF
ON ES.PF_CODE = PRF.PF_CODE
WHERE
SURVEY_YEAR = 2020
GROUP BY
SURVEY_YEAR,
PF_NAME
) BASE
WHERE AMT is not null
UNION ALL
SELECT
SURVEY_YEAR as 'SV_YEAR',
PF_NAME as 'PREFECTURE',
'短大' as 'KIND',
3 as 'NO',
p,
JUNIOR_CLG as 'AMT'
FROM
(SELECT
SURVEY_YEAR,
PF_NAME,
SUM(JUNIOR_CLG) as 'JUNIOR_CLG',
ES.PF_CODE as p
FROM
ENROLLMENT_STATUS ES
LEFT JOIN
PREFECTURE PRF
ON ES.PF_CODE = PRF.PF_CODE
WHERE
SURVEY_YEAR = 2020
GROUP BY
SURVEY_YEAR,
PF_NAME
) BASE
WHERE AMT is not null
UNION ALL
SELECT
SURVEY_YEAR as 'SV_YEAR',
PF_NAME as 'PREFECTURE',
'大学' as 'KIND',
4 as 'NO',
p,
COLLEGE as 'AMT'
FROM
(SELECT
SURVEY_YEAR,
PF_NAME,
SUM(COLLEGE) as 'COLLEGE',
ES.PF_CODE as p
FROM
ENROLLMENT_STATUS ES
LEFT JOIN
PREFECTURE PRF
ON ES.PF_CODE = PRF.PF_CODE
WHERE
SURVEY_YEAR = 2020
GROUP BY
SURVEY_YEAR,
PF_NAME
) BASE
WHERE AMT is not null
UNION ALL
SELECT
SURVEY_YEAR as 'SV_YEAR',
PF_NAME as 'PREFECTURE',
'大学院' as 'KIND',
5 as 'NO',
p,
GRADUATE as 'AMT'
FROM
(SELECT
SURVEY_YEAR,
PF_NAME,
SUM(GRADUATE) as 'GRADUATE',
ES.PF_CODE as p
FROM
ENROLLMENT_STATUS ES
LEFT JOIN
PREFECTURE PRF
ON ES.PF_CODE = PRF.PF_CODE
WHERE
SURVEY_YEAR = 2020
GROUP BY
SURVEY_YEAR,
PF_NAME
) BASE
WHERE AMT is not null
order by p,NO)
提出情報
提出日時 | 2023/12/12 11:37:03 |
コンテスト | 第2回 SQLコンテスト |
問題 | 就学状況の表示変換 |
受験者 | yoshino |
状態 (詳細) | AC (Accepted: 正答) |
メモリ使用量 | 86 MB |
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
86 MB
データパターン2
AC
84 MB