コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
WITH HEIGHT_AVG AS (
SELECT
AGE
, ROUND(
SUM(CASE CATEGORY_CODE
WHEN '10' THEN AVERAGE_VALUE
ELSE 0
END) /
SUM(CASE CATEGORY_CODE
WHEN '10' THEN 1
ELSE 0
END)
, 1)
AS
H_AVG
FROM
SCHOOL_HEALTH
WHERE
SURVEY_YEAR = 2019
GROUP BY
AGE
, GENDER_CODE
),
HEIGHT_RATE AS (
SELECT
AGE
, COUNT(AVERAGE_VALUE > HEIGHT_AVG.H_AVG) / COUNT(*) AS H_PER
FROM
SCHOOL_HEALTH
JOIN
HEIGHT_RATE
ON
HEIGHT_RATE.AGE = HEIGHT_AVG.AGE
WHERE
SURVEY_YEAR = 2019
GROUP BY
AGE
, GENDER_CODE
),
WEIGHT_AVG AS (
SELECT
AGE
, ROUND(
SUM(CASE CATEGORY_CODE
WHEN '20' THEN AVERAGE_VALUE
ELSE 0
END) /
SUM(CASE CATEGORY_CODE
WHEN '20' THEN 1
ELSE 0
END)
, 1)
AS
W_AVG
FROM
SCHOOL_HEALTH
WHERE
SURVEY_YEAR = 2019
GROUP BY
AGE
, GENDER_CODE
),
WEIGHT_RATE AS (
SELECT
AGE
, COUNT(AVERAGE_VALUE > WEIGHT_AVG.W_AVG) / COUNT(*) AS H_PER
FROM
SCHOOL_HEALTH
JOIN
WEIGHT_RATE
ON
WEIGHT_RATE.AGE = WEIGHT_AVG.AGE
WHERE
SURVEY_YEAR = 2019
GROUP BY
AGE
, GENDER_CODE
)
SELECT
SCHOOL_HEALTH.AGE
, CASE GENDER_CODE
WHEN '20' THEN 'MALE'
ELSE 'FEMALE'
END AS GENDER
FROM
SCHOOL_HEALTH
JOIN
HEIGHT_RATE
ON
SCHOOL_HEALTH.AGE = HEIGHT_RATE.AGE
JOIN
WEIGHT_RATE
ON
WEIGHT_RATE.AGE = SCHOOL_HEALTH.AGE
WHERE
SURVEY_YEAR = 2019
GROUP BY
SCHOOL_HEALTH.AGE
, GENDER
ORDER BY
SCHOOL_HEALTH.AGE DESC
, GENDER_CODE DESC;
提出情報
提出日時 | 2024/07/23 16:26:28 |
コンテスト | 第8回 SQLコンテスト |
問題 | 身長と体重 |
受験者 | ogata24026 |
状態 (詳細) | RE (Runtime Error: 実行時エラー) |
メモリ使用量 | 85 MB |
メッセージ
SQLITE_ERROR: circular reference: HEIGHT_RATE
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
RE
84 MB
データパターン2
RE
85 MB