ソースコード
with t0 as 
(
    select 
        *
        from AGE_GRP
)
, t1 as 
(
    select 
        *
        from SLEEP_TIME
)
, t2 as
(
    select 
        *
        from sleep_time_dtl
)
, t3 as 
(
    select 
        age_name, t0.age_code, time_code, 
        target_pop
        from t2
        left join t0
        on t2.age_code=t0.age_code
)
, t4 as 
(
    select 
        age_name, time_name, t3.time_code, 
        target_pop
        from t3
        left join t1
        on t3.time_code=t1.time_code
)
, t5 as 
(
    select 
        age_name, time_name, time_code, 
        sum(target_pop) as count_
        from t4
        group by age_name, time_name, time_code
)
, t6 as 
(
    select 
        age_name, 
        count_, 
        case when time_code=120 then count_ else 0 end as col1 , 
        case when time_code=130 then count_ else 0 end as col2, 
        case when time_code=140 then count_ else 0 end as col3, 
        case when time_code=150 then count_ else 0 end as col4, 
        case when time_code=160 then count_ else 0 end as col5, 
        case when time_code=170 then count_ else 0 end as col6,
        case when time_code=180 then count_ else 0 end as col7
        from t5
)
, t7 as 
(
    select 
        age_name, 
        sum(col1) as '5時間未満', 
        sum(col2) as '5時間以上6時間未満', 
        sum(col3) as '6時間以上7時間未満',
        sum(col4) as '7時間以上8時間未満', 
        sum(col5) as '8時間以上9時間未満', 
        sum(col6) as '9時間以上', 
        sum(col7) as '不詳'
        from t6
        group by age_name
        
)
select * from t7
提出情報
提出日時2022/07/20 17:31:34
コンテスト練習用コンテスト
問題年齢別睡眠時間分析
受験者otooo
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量100 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
98 MB
データパターン2
WA
100 MB