ソースコード
with master as (
select age_name
, case time_code
when 120 then target_pop end as time120
, case time_code
when 130 then target_pop end as time130
, case time_code
when 140 then target_pop end as time140
, case time_code
when 150 then target_pop end as time150
, case time_code
when 160 then target_pop end as time160
, case time_code
when 170 then target_pop end as time170
, case time_code
when 180 then target_pop end as time180
from(
select a.age_name as age_name, s.time_code as time_code, s.time_name as time_name, sd.target_pop as target_pop
from sleep_time_dtl as sd
left join sleep_time as s
using(time_code)
left join age_grp as a
using(age_code)
))

select age_name as 年齢階層
, sum(time120) as '5時間未満'
, sum(time130) as '5時間以上6時間未満'
, sum(time140) as '6時間以上7時間未満'
, sum(time150) as '7時間以上8時間未満'
, sum(time160) as '8時間以上9時間未満'
, sum(time170) as '9時間以上'
, sum(time180) as '不詳'
from master
group by age_name
order by 1
提出情報
提出日時2022/07/08 07:18:06
コンテスト練習用コンテスト
問題年齢別睡眠時間分析
受験者kazkida
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量79 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
78 MB
データパターン2
AC
79 MB