コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
SELECT
SURVEY_2022.AREA_CODE AS CODE
,AREA.AREA_NAME AS NAME
,SURVEY_2022.[RANK] AS [2022_RANK]
,SURVEY_2022.[RATIO] || '%' AS [2022_RATIO]
,SURVEY_2017.[RANK] AS [2017_RANK]
,SURVEY_2017.[RATIO] || '%' AS [2017_RATIO]
,SURVEY_2012.[RANK] AS [2012_RANK]
,SURVEY_2012.[RATIO] || '%' AS [2012_RATIO]
FROM (
SELECT
AREA_CODE
,DENSE_RANK() OVER(ORDER BY ROUND(CAST(FOOD_EXP * 100 AS REAL) / CAST(CONSUMPTION_EXP AS REAL), 1)) AS [RANK]
,ROUND(CAST(FOOD_EXP * 100 AS REAL) / CAST(CONSUMPTION_EXP AS REAL), 1) AS [RATIO]
FROM HOUSEHOLD_SURVEY
WHERE SURVEY_YEAR = 2022
) AS SURVEY_2022
INNER JOIN AREA
ON AREA.AREA_CODE = SURVEY_2022.AREA_CODE
LEFT OUTER JOIN (
SELECT
AREA_CODE
,DENSE_RANK() OVER(ORDER BY ROUND(CAST(FOOD_EXP * 100 AS REAL) / CAST(CONSUMPTION_EXP AS REAL), 1)) AS [RANK]
,ROUND(CAST(FOOD_EXP * 100 AS REAL) / CAST(CONSUMPTION_EXP AS REAL), 1) AS [RATIO]
FROM HOUSEHOLD_SURVEY
WHERE SURVEY_YEAR = 2017
) AS SURVEY_2017
ON SURVEY_2017.AREA_CODE = SURVEY_2022.AREA_CODE
LEFT OUTER JOIN (
SELECT
AREA_CODE
,DENSE_RANK() OVER(ORDER BY ROUND(CAST(FOOD_EXP * 100 AS REAL) / CAST(CONSUMPTION_EXP AS REAL), 1)) AS [RANK]
,ROUND(CAST(FOOD_EXP * 100 AS REAL) / CAST(CONSUMPTION_EXP AS REAL), 1) AS [RATIO]
FROM HOUSEHOLD_SURVEY
WHERE SURVEY_YEAR = 2012
) AS SURVEY_2012
ON SURVEY_2012.AREA_CODE = SURVEY_2022.AREA_CODE
ORDER BY
SURVEY_2022.[RANK] ASC
,SURVEY_2022.AREA_CODE DESC
;
提出情報
提出日時 | 2023/12/18 01:08:24 |
コンテスト | 第10回 SQLコンテスト |
問題 | 食料費の割合 |
受験者 | shirai_a |
状態 (詳細) | AC (Accepted: 正答) |
メモリ使用量 | 89 MB |
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
89 MB
データパターン2
AC
87 MB
データパターン3
AC
88 MB