ソースコード
WITH base AS (
    SELECT
        a.AGE_NAME,
        std.AGE_CODE,
        std.TIME_CODE,
        SUM(std.TARGET_POP) AS SUM_POP
    FROM
        SLEEP_TIME_DTL AS std,
        AGE_GRP AS a
    WHERE
        std.AGE_CODE = a.AGE_CODE
    GROUP BY
        a.AGE_CODE, std.TIME_CODE
)

SELECT 
    DISTINCT b0.AGE_NAME AS 年齢階層,
    b1.SUM_POP AS "5時間未満",
    b2.SUM_POP AS "5時間以上6時間未満",
    b3.SUM_POP AS "6時間以上7時間未満",
    b4.SUM_POP AS "7時間以上8時間未満",
    b5.SUM_POP AS "8時間以上9時間未満",
    b6.SUM_POP AS "9時間以上",
    b7.SUM_POP AS 不詳
FROM base AS b0
LEFT JOIN base AS b1
ON 
    b0.AGE_CODE = b1.AGE_CODE AND
    b1.TIME_CODE = 120
LEFT JOIN base AS b2
ON 
    b0.AGE_CODE = b2.AGE_CODE AND
    b2.TIME_CODE = 130
LEFT JOIN base AS b3
ON 
    b0.AGE_CODE = b3.AGE_CODE AND
    b3.TIME_CODE = 140
LEFT JOIN base AS b4
ON 
    b0.AGE_CODE = b4.AGE_CODE AND
    b4.TIME_CODE = 150
LEFT JOIN base AS b5
ON 
    b0.AGE_CODE = b5.AGE_CODE AND
    b5.TIME_CODE = 160
LEFT JOIN base AS b6
ON 
    b0.AGE_CODE = b6.AGE_CODE AND
    b6.TIME_CODE = 170
LEFT JOIN base AS b7
ON 
    b0.AGE_CODE = b7.AGE_CODE AND
    b7.TIME_CODE = 180
    
提出情報
提出日時2022/07/04 14:02:29
コンテスト練習用コンテスト
問題年齢別睡眠時間分析
受験者money4_jam
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量80 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
79 MB
データパターン2
AC
80 MB