ソースコード
CREATE TEMPORARY TABLE SUM_POP AS
    SELECT
        SLEEP_TIME_DTL.AGE_CODE
        ,SUM(SLEEP_TIME_DTL.SP_TIME_5) AS SP_TIME_5
        ,SUM(SLEEP_TIME_DTL.SP_TIME_6) AS SP_TIME_6
        ,SUM(SLEEP_TIME_DTL.SP_TIME_7) AS SP_TIME_7
        ,SUM(SLEEP_TIME_DTL.SP_TIME_8) AS SP_TIME_8
        ,SUM(SLEEP_TIME_DTL.SP_TIME_9) AS SP_TIME_9
        ,SUM(SLEEP_TIME_DTL.SP_TIME_9OVER) AS SP_TIME_9OVER
    FROM
        SLEEP_TIME_DTL
    WHERE
        SLEEP_TIME_DTL.PF_CODE IN ("01000", "02000", "03000", "04000", "07000")
    GROUP BY SLEEP_TIME_DTL.AGE_CODE
;

SELECT
    AGE_GRP.AGE_CODE AS "年齢コード"
    ,AGE_GRP.AGE_NAME AS "年齢階層名"    
    ,SUM_POP.SP_TIME_5 AS "5時間未満"
    ,SUM_POP.SP_TIME_6 AS "5時間以上6時間未満"
    ,SUM_POP.SP_TIME_7 AS "6時間以上7時間未満"
    ,SUM_POP.SP_TIME_8 AS "7時間以上8時間未満"
    ,SUM_POP.SP_TIME_9 AS "8時間以上9時間未満"
    ,SUM_POP.SP_TIME_9OVER AS "9時間以上"
FROM
    AGE_GRP
LEFT JOIN SUM_POP ON AGE_GRP.AGE_CODE = SUM_POP.AGE_CODE
ORDER BY AGE_GRP.AGE_CODE
;
提出情報
提出日時2022/09/21 22:25:31
コンテスト第1回 SQLコンテスト
問題睡眠時間帯別集計
受験者hashigo
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量104 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
104 MB
データパターン2
AC
101 MB