ソースコード
with temp as (
              select
                t3.AGE_NAME
                ,case
                    when t2.TIME_CODE = 120 then t1.TARGET_POP else 0 
                end t1
                ,case
                    when t2.TIME_CODE = 130 then t1.TARGET_POP else 0 
                end t2
                ,case
                    when t2.TIME_CODE = 140 then t1.TARGET_POP else 0 
                end t3
                ,case
                    when t2.TIME_CODE = 150 then t1.TARGET_POP else 0 
                end t4
                ,case
                    when t2.TIME_CODE = 160 then t1.TARGET_POP else 0 
                end t5
                ,case
                    when t2.TIME_CODE = 170 then t1.TARGET_POP else 0 
                end t6
                ,case
                    when t2.TIME_CODE = 180 then t1.TARGET_POP else 0 
                end t7
              from
                SLEEP_TIME_DTL t1
              inner join
                SLEEP_TIME t2 on t1.TIME_CODE = t2.TIME_CODE
              inner join
                AGE_GRP t3 on t1.AGE_CODE = t3.AGE_CODE
             )
select
    AGE_NAME as '年齢階層'
    ,sum(t1) as '5時間未満'
    ,sum(t2) as '5時間以上6時間未満'
    ,sum(t3) as '6時間以上7時間未満'
    ,sum(t4) as '7時間以上8時間未満'
    ,sum(t5) as '8時間以上9時間未満'
    ,sum(t6) as '9時間以上'
    ,sum(t7) as '不詳'
from
    temp
group by
    AGE_NAME
order by
    AGE_NAME
;

提出情報
提出日時2022/07/10 01:39:21
コンテスト練習用コンテスト
問題年齢別睡眠時間分析
受験者s1224
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量78 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
78 MB
データパターン2
AC
76 MB