ソースコード
SELECT
    AG.AGE_NAME AS '年齢階層',
    TB1.TOTAL AS '5時間未満',
    TB2.TOTAL AS '5時間以上6時間未満',
    TB3.TOTAL AS '6時間以上7時間未満',
    TB4.TOTAL AS '7時間以上8時間未満',
    TB5.TOTAL AS '8時間以上9時間未満',
    TB6.TOTAL AS '9時間以上',
    TB7.TOTAL AS '不詳'
FROM
    SLEEP_TIME_DTL SL
    INNER JOIN AGE_GRP AG ON SL.AGE_CODE = AG.AGE_CODE
    INNER JOIN SLEEP_TIME ST ON SL.TIME_CODE = ST.TIME_CODE
    LEFT JOIN
        (
            SELECT
                t1.AGE_CODE,
                SUM(t1.TARGET_POP) AS TOTAL
            FROM
                SLEEP_TIME_DTL t1
            WHERE
                TIME_CODE = 120
            GROUP BY
                t1.AGE_CODE
        ) TB1 ON SL.AGE_CODE = TB1.AGE_CODE
    LEFT JOIN
        (
            SELECT
                t2.AGE_CODE,
                SUM(t2.TARGET_POP) AS TOTAL
            FROM
                SLEEP_TIME_DTL t2
            WHERE
                TIME_CODE = 130
            GROUP BY
                t2.AGE_CODE
        ) TB2 ON SL.AGE_CODE = TB2.AGE_CODE
    LEFT JOIN
        (
            SELECT
                t3.AGE_CODE,
                SUM(t3.TARGET_POP) AS TOTAL
            FROM
                SLEEP_TIME_DTL t3
            WHERE
                TIME_CODE = 140
            GROUP BY
                t3.AGE_CODE
        ) TB3 ON SL.AGE_CODE = TB3.AGE_CODE
    LEFT JOIN
        (
            SELECT
                t4.AGE_CODE,
                SUM(t4.TARGET_POP) AS TOTAL
            FROM
                SLEEP_TIME_DTL t4
            WHERE
                TIME_CODE = 150
            GROUP BY
                t4.AGE_CODE
        ) TB4 ON SL.AGE_CODE = TB4.AGE_CODE
    LEFT JOIN
        (
            SELECT
                t5.AGE_CODE,
                SUM(t5.TARGET_POP) AS TOTAL
            FROM
                SLEEP_TIME_DTL t5
            WHERE
                TIME_CODE = 160
            GROUP BY
                t5.AGE_CODE
        ) TB5 ON SL.AGE_CODE = TB5.AGE_CODE
    LEFT JOIN
        (
            SELECT
                t6.AGE_CODE,
                SUM(t6.TARGET_POP) AS TOTAL
            FROM
                SLEEP_TIME_DTL t6
            WHERE
                TIME_CODE = 170
            GROUP BY
                t6.AGE_CODE
        ) TB6 ON SL.AGE_CODE = TB6.AGE_CODE
    LEFT JOIN
        (
            SELECT
                t7.AGE_CODE,
                SUM(t7.TARGET_POP) AS TOTAL
            FROM
                SLEEP_TIME_DTL t7
            WHERE
                TIME_CODE = 180
            GROUP BY
                t7.AGE_CODE
        ) TB7 ON SL.AGE_CODE = TB7.AGE_CODE
GROUP BY
    SL.AGE_CODE
ORDER BY
    SL.AGE_CODE ASC
提出情報
提出日時2024/06/04 13:29:17
コンテスト練習用コンテスト
問題年齢別睡眠時間分析
受験者nocopylight
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
84 MB