ソースコード
WITH
SLEPT_5 AS (
    SELECT
        AGE_CODE,
        COUNT(*) AS SLEPT_5
    FROM
        SLEEP_TIME_DTL
    WHERE
        TIME_CODE = 120
    GROUP BY
        AGE_CODE
),

SLEPT_5_6 AS (
    SELECT
        AGE_CODE,
        COUNT(*) AS SLEPT_5_6
    FROM
        SLEEP_TIME_DTL
    WHERE
        TIME_CODE = 130
    GROUP BY
        AGE_CODE
),

SLEPT_6_7 AS (
    SELECT
        AGE_CODE,
        COUNT(*) AS SLEPT_6_7
    FROM
        SLEEP_TIME_DTL
    WHERE
        TIME_CODE = 140
    GROUP BY
        AGE_CODE
),

SLEPT_7_8 AS (
    SELECT
        AGE_CODE,
        COUNT(*) AS SLEPT_7_8
    FROM
        SLEEP_TIME_DTL
    WHERE
        TIME_CODE = 150
    GROUP BY
        AGE_CODE
),

SLEPT_8_9 AS (
    SELECT
        AGE_CODE,
        COUNT(*) AS SLEPT_8_9
    FROM
        SLEEP_TIME_DTL
    WHERE
        TIME_CODE = 160
    GROUP BY
        AGE_CODE
),

SLEPT_9_ AS (
    SELECT
        AGE_CODE,
        COUNT(*) AS SLEPT_9_
    FROM
        SLEEP_TIME_DTL
    WHERE
        TIME_CODE = 170
    GROUP BY
        AGE_CODE
),

SLEPT_Un AS (
    SELECT
        AGE_CODE,
        COUNT(*) AS SLEPT_Un
    FROM
        SLEEP_TIME_DTL
    WHERE
        TIME_CODE = 180
    GROUP BY
        AGE_CODE
)

SELECT
    AGE_NAME AS 年齢階層,
    SLEPT_5 AS "5時間未満",
    SLEPT_5_6 AS "5時間以上6時間未満",
    SLEPT_6_7 AS "6時間以上7時間未満",
    SLEPT_7_8 AS "7時間以上8時間未満",
    SLEPT_8_9 AS "8時間以上9時間未満",
    SLEPT_9_ AS "9時間以上",
    SLEPT_Un AS 不詳
FROM
    AGE_GRP
        LEFT JOIN
            SLEPT_5
            ON
                AGE_GRP.AGE_CODE = SLEPT_5.AGE_CODE
        LEFT JOIN
            SLEPT_5_6
            ON
                AGE_GRP.AGE_CODE = SLEPT_5_6.AGE_CODE
        LEFT JOIN
            SLEPT_6_7
            ON
                AGE_GRP.AGE_CODE = SLEPT_6_7.AGE_CODE
        LEFT JOIN
            SLEPT_7_8
            ON
                AGE_GRP.AGE_CODE = SLEPT_7_8.AGE_CODE
        LEFT JOIN
            SLEPT_8_9
            ON
                AGE_GRP.AGE_CODE = SLEPT_8_9.AGE_CODE
        LEFT JOIN
            SLEPT_9_
            ON
                AGE_GRP.AGE_CODE = SLEPT_9_.AGE_CODE
        LEFT JOIN
            SLEPT_Un
            ON
                AGE_GRP.AGE_CODE = SLEPT_Un.AGE_CODE
    WHERE
        AGE_GRP.AGE_CODE BETWEEN 2 AND 6
ORDER BY
    AGE_GRP.AGE_CODE
提出情報
提出日時2023/02/22 10:25:59
コンテスト練習用コンテスト
問題年齢別睡眠時間分析
受験者Kanayama_Koyane
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量81 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
81 MB
データパターン2
WA
78 MB