ソースコード
SELECT 
a.AGE_NAME AS '年齢階層', 
t1.sum AS '5時間未満', 
t2.sum AS '5時間以上6時間未満',
t3.sum AS '6時間以上7時間未満',
t4.sum AS '7時間以上8時間未満',
t5.sum AS '8時間以上9時間未満',
t6.sum AS '9時間以上',
t7.sum AS '不詳'
FROM (
  SELECT AGE_CODE, SUM(TARGET_POP) AS sum
  FROM SLEEP_TIME_DTL
  WHERE TIME_CODE = 120
  GROUP BY AGE_CODE
) AS t1
INNER JOIN
(
  SELECT AGE_CODE, SUM(TARGET_POP) AS sum
  FROM SLEEP_TIME_DTL
  WHERE TIME_CODE = 130
  GROUP BY AGE_CODE
) AS t2
ON t1.AGE_CODE = t2.AGE_CODE
INNER JOIN
(
  SELECT AGE_CODE, SUM(TARGET_POP) AS sum
  FROM SLEEP_TIME_DTL
  WHERE TIME_CODE = 140
  GROUP BY AGE_CODE
) AS t3
ON t1.AGE_CODE = t3.AGE_CODE
INNER JOIN
(
  SELECT AGE_CODE, SUM(TARGET_POP) AS sum
  FROM SLEEP_TIME_DTL
  WHERE TIME_CODE = 150
  GROUP BY AGE_CODE
) AS t4
ON t1.AGE_CODE = t4.AGE_CODE
INNER JOIN
(
  SELECT AGE_CODE, SUM(TARGET_POP) AS sum
  FROM SLEEP_TIME_DTL
  WHERE TIME_CODE = 160
  GROUP BY AGE_CODE
) AS t5
ON t1.AGE_CODE = t5.AGE_CODE
INNER JOIN
(
  SELECT AGE_CODE, SUM(TARGET_POP) AS sum
  FROM SLEEP_TIME_DTL
  WHERE TIME_CODE = 170
  GROUP BY AGE_CODE
) AS t6
ON t1.AGE_CODE = t6.AGE_CODE
INNER JOIN
(
  SELECT AGE_CODE, SUM(TARGET_POP) AS sum
  FROM SLEEP_TIME_DTL
  WHERE TIME_CODE = 180
  GROUP BY AGE_CODE
) AS t7
ON t1.AGE_CODE = t7.AGE_CODE
INNER JOIN AGE_GRP AS a
ON t1.AGE_CODE = a.AGE_CODE
ORDER BY t1.AGE_CODE
提出情報
提出日時2022/07/18 14:58:33
コンテスト練習用コンテスト
問題年齢別睡眠時間分析
受験者tk
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量88 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
88 MB
データパターン2
AC
85 MB