ソースコード
select
  t1.AGE_NAME as 年齢階層
  , a1.s as '5時間未満'
  , a2.s as '5時間以上6時間未満'
  , a3.s as '6時間以上7時間未満'
  , a4.s as '7時間以上8時間未満'
  , a5.s as '8時間以上9時間未満'
  , a6.s as '9時間以上'
  , a7.s as 不詳
from
  AGE_GRP t1
  -- 5時間未満
  left join (select AGE_CODE,SUM(TARGET_POP) s from SLEEP_TIME_DTL where TIME_CODE = 120 GROUP BY AGE_CODE) a1
    on t1.AGE_CODE = a1.AGE_CODE
  -- 5時間以上6時間未満
  inner join (select AGE_CODE,SUM(TARGET_POP) s from SLEEP_TIME_DTL where TIME_CODE = 130 GROUP BY AGE_CODE) a2
    on t1.AGE_CODE = a2.AGE_CODE
  -- 6時間以上7時間未満
  inner join (select AGE_CODE,SUM(TARGET_POP) s from SLEEP_TIME_DTL where TIME_CODE = 140 GROUP BY AGE_CODE) a3
    on t1.AGE_CODE = a3.AGE_CODE
  -- 7時間以上8時間未満
  inner join (select AGE_CODE,SUM(TARGET_POP) s from SLEEP_TIME_DTL where TIME_CODE = 150 GROUP BY AGE_CODE) a4
    on t1.AGE_CODE = a4.AGE_CODE
  -- 8時間以上9時間未満
  inner join (select AGE_CODE,SUM(TARGET_POP) s from SLEEP_TIME_DTL where TIME_CODE = 160 GROUP BY AGE_CODE) a5
    on t1.AGE_CODE = a5.AGE_CODE
  -- 9時間以上
  inner join (select AGE_CODE,SUM(TARGET_POP) s from SLEEP_TIME_DTL where TIME_CODE = 170 GROUP BY AGE_CODE) a6
    on t1.AGE_CODE = a6.AGE_CODE
  -- 不詳
  inner join (select AGE_CODE,SUM(TARGET_POP) s from SLEEP_TIME_DTL where TIME_CODE = 180 GROUP BY AGE_CODE) a7
    on t1.AGE_CODE = a7.AGE_CODE
order by
  t1.AGE_CODE
;
提出情報
提出日時2022/09/21 11:41:30
コンテスト練習用コンテスト
問題年齢別睡眠時間分析
受験者oka
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量81 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
81 MB
データパターン2
AC
81 MB