ソースコード
CREATE TEMPORARY TABLE agg_table as
  SELECT
    AGE_CODE,
    TIME_CODE,
    SUM(TARGET_POP) as sum
  FROM
    SLEEP_TIME_DTL
  GROUP BY TIME_CODE, AGE_CODE;

SELECT
  AGE_NAME AS '年齢階層',
  sum120 AS '5時間未満',
  sum130 AS '5時間以上6時間未満',
  sum140 AS '6時間以上7時間未満',
  sum150 AS '7時間以上8時間未満',
  sum160 AS '8時間以上9時間未満',
  sum170 AS '9時間以上',
  sum180 AS '不詳'
FROM
  (SELECT AGE_CODE as age120, sum as sum120 FROM agg_table WHERE TIME_CODE = 120)
  LEFT JOIN
    (SELECT AGE_CODE as age130, sum as sum130 FROM agg_table WHERE TIME_CODE = 130)
  ON age120 = age130
  LEFT JOIN
    (SELECT AGE_CODE as age140, sum as sum140 FROM agg_table WHERE TIME_CODE = 140)
  ON age120 = age140
  LEFT JOIN
    (SELECT AGE_CODE as age150, sum as sum150 FROM agg_table WHERE TIME_CODE = 150)
  ON age120 = age150
  LEFT JOIN
    (SELECT AGE_CODE as age160, sum as sum160 FROM agg_table WHERE TIME_CODE = 160)
  ON age120 = age160
  LEFT JOIN
    (SELECT AGE_CODE as age170, sum as sum170 FROM agg_table WHERE TIME_CODE = 170)
  ON age120 = age170
  LEFT JOIN
    (SELECT AGE_CODE as age180, sum as sum180 FROM agg_table WHERE TIME_CODE = 180)
  ON age120 = age180
  LEFT JOIN AGE_GRP
  ON age120 = AGE_GRP.AGE_CODE
    
提出情報
提出日時2022/07/14 10:32:22
コンテスト練習用コンテスト
問題年齢別睡眠時間分析
受験者sh
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量84 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
76 MB