ソースコード
with x as (
SELECT
   distinct
     TIME_CODE
    ,age_code
    ,sum(TARGET_POP) over (partition by time_code,age_code) as total
from
    SLEEP_TIME_DTL
)

SELECT
    AGE_NAME as 年齢階層
    ,(select total from x t2 where t1.AGE_CODE = t2.AGE_CODE and TIME_CODE = 120) as "5時間未満"
    ,(select total from x t2 where t1.AGE_CODE = t2.AGE_CODE and TIME_CODE = 130) as "5時間以上6時間未満"
    ,(select total from x t2 where t1.AGE_CODE = t2.AGE_CODE and TIME_CODE = 140) as "6時間以上7時間未満"
    ,(select total from x t2 where t1.AGE_CODE = t2.AGE_CODE and TIME_CODE = 150) as "7時間以上8時間未満"
    ,(select total from x t2 where t1.AGE_CODE = t2.AGE_CODE and TIME_CODE = 160) as "8時間以上9時間未満"
    ,(select total from x t2 where t1.AGE_CODE = t2.AGE_CODE and TIME_CODE = 170) as "9時間以上"
    ,(select total from x t2 where t1.AGE_CODE = t2.AGE_CODE and TIME_CODE = 180) as "不詳"
FROM
    AGE_GRP t1
where
    t1.AGE_CODE IN (select distinct AGE_CODE FROM SLEEP_TIME_DTL)
ORDER BY age_code asc
提出情報
提出日時2023/04/12 01:10:41
コンテスト練習用コンテスト
問題年齢別睡眠時間分析
受験者kkinjoh
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量79 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
79 MB
データパターン2
AC
77 MB