ソースコード
WITH POP_BY_AGE AS (
  SELECT
    AGE_CODE,
    TIME_CODE,
    SUM(TARGET_POP) AS TOT_TAR_POP
  FROM SLEEP_TIME_DTL
  GROUP BY TIME_CODE, AGE_CODE
)

SELECT
  AG.AGE_NAME AS '年齢階層'
  ,SUM(CASE WHEN TIME_CODE = 120 THEN TOT_TAR_POP ELSE '0' END) AS '5時間未満'
  ,SUM(CASE WHEN TIME_CODE = 130 THEN TOT_TAR_POP ELSE '0' END) AS '5時間以上6時間未満'
  ,SUM(CASE WHEN TIME_CODE = 140 THEN TOT_TAR_POP ELSE '0' END) AS '6時間以上7時間未満'
  ,SUM(CASE WHEN TIME_CODE = 150 THEN TOT_TAR_POP ELSE '0' END) AS '7時間以上8時間未満'
  ,SUM(CASE WHEN TIME_CODE = 160 THEN TOT_TAR_POP ELSE '0' END) AS '8時間以上9時間未満'
  ,SUM(CASE WHEN TIME_CODE = 170 THEN TOT_TAR_POP ELSE '0' END) AS '9時間以上'
  ,SUM(CASE WHEN TIME_CODE = 180 THEN TOT_TAR_POP ELSE '0' END) AS '不詳'

FROM POP_BY_AGE AS PBA

    INNER JOIN AGE_GRP AS AG
    ON AG.AGE_CODE = PBA.AGE_CODE 
GROUP BY 
    年齢階層
ORDER BY 
    AG.AGE_CODE;
提出情報
提出日時2024/06/04 17:07:48
コンテスト練習用コンテスト
問題年齢別睡眠時間分析
受験者512441
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
86 MB
データパターン2
AC
84 MB