ソースコード
SELECT
     AG.AGE_NAME AS '年齢階層'
    ,STD120.TP AS '5時間未満'
    ,STD130.TP AS '5時間以上6時間未満'
    ,STD140.TP AS '6時間以上7時間未満'
    ,STD150.TP AS '7時間以上8時間未満'
    ,STD160.TP AS '8時間以上9時間未満'
    ,STD170.TP AS '9時間以上'
    ,STD180.TP AS '不詳'
FROM
(
    SELECT
        AGE_CODE
    FROM
        SLEEP_TIME_DTL
    GROUP BY
        AGE_CODE
) AS STD
    
LEFT OUTER JOIN
    AGE_GRP AS AG
ON
    AG.AGE_CODE = STD.AGE_CODE

LEFT OUTER JOIN
(
    SELECT
         AGE_CODE
        ,SUM(TARGET_POP) AS TP
    FROM
        SLEEP_TIME_DTL
    WHERE
        TIME_CODE = 120
    GROUP BY
        AGE_CODE
) AS STD120
ON
    STD120.AGE_CODE = STD.AGE_CODE

LEFT OUTER JOIN
(
    SELECT
         AGE_CODE
        ,SUM(TARGET_POP) AS TP
    FROM
        SLEEP_TIME_DTL
    WHERE
        TIME_CODE = 130
    GROUP BY
        AGE_CODE
) AS STD130
ON
    STD130.AGE_CODE = STD.AGE_CODE

LEFT OUTER JOIN
(
    SELECT
         AGE_CODE
        ,SUM(TARGET_POP) AS TP
    FROM
        SLEEP_TIME_DTL
    WHERE
        TIME_CODE = 140
    GROUP BY
        AGE_CODE
) AS STD140
ON
    STD140.AGE_CODE = STD.AGE_CODE

LEFT OUTER JOIN
(
    SELECT
         AGE_CODE
        ,SUM(TARGET_POP) AS TP
    FROM
        SLEEP_TIME_DTL
    WHERE
        TIME_CODE = 150
    GROUP BY
        AGE_CODE
) AS STD150
ON
    STD150.AGE_CODE = STD.AGE_CODE

LEFT OUTER JOIN
(
    SELECT
         AGE_CODE
        ,SUM(TARGET_POP) AS TP
    FROM
        SLEEP_TIME_DTL
    WHERE
        TIME_CODE = 160
    GROUP BY
        AGE_CODE
) AS STD160
ON
    STD160.AGE_CODE = STD.AGE_CODE

LEFT OUTER JOIN
(
    SELECT
         AGE_CODE
        ,SUM(TARGET_POP) AS TP
    FROM
        SLEEP_TIME_DTL
    WHERE
        TIME_CODE = 170
    GROUP BY
        AGE_CODE
) AS STD170
ON
    STD170.AGE_CODE = STD.AGE_CODE

LEFT OUTER JOIN
(
    SELECT
         AGE_CODE
        ,SUM(TARGET_POP) AS TP
    FROM
        SLEEP_TIME_DTL
    WHERE
        TIME_CODE = 180
    GROUP BY
        AGE_CODE
) AS STD180
ON
    STD180.AGE_CODE = STD.AGE_CODE
    
ORDER BY
    STD.AGE_CODE ASC
提出情報
提出日時2024/02/13 17:16:02
コンテスト練習用コンテスト
問題年齢別睡眠時間分析
受験者mo
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量93 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
93 MB
データパターン2
AC
84 MB