ソースコード
SELECT
AGE_NAME AS 年齢階層,
COALESCE(A.X, 0) AS '5時間未満',
COALESCE(B.X, 0) AS '5時間以上6時間未満',
COALESCE(C.X, 0) AS '6時間以上7時間未満',
COALESCE(D.X, 0) AS '7時間以上8時間未満',
COALESCE(E.X, 0) AS '8時間以上9時間未満',
COALESCE(F.X, 0) AS '9時間以上',
COALESCE(G.X, 0) AS '不詳'
FROM AGE_GRP
LEFT JOIN (SELECT SUM(TARGET_POP) AS X, AGE_CODE FROM SLEEP_TIME_DTL
    WHERE TIME_CODE=120 GROUP BY AGE_CODE) AS A USING(AGE_CODE)
LEFT JOIN (SELECT SUM(TARGET_POP) AS X, AGE_CODE FROM SLEEP_TIME_DTL
    WHERE TIME_CODE=130 GROUP BY AGE_CODE) AS B USING(AGE_CODE)
LEFT JOIN (SELECT SUM(TARGET_POP) AS X, AGE_CODE FROM SLEEP_TIME_DTL
    WHERE TIME_CODE=140 GROUP BY AGE_CODE) AS C USING(AGE_CODE)
LEFT JOIN (SELECT SUM(TARGET_POP) AS X, AGE_CODE FROM SLEEP_TIME_DTL
    WHERE TIME_CODE=150 GROUP BY AGE_CODE) AS D USING(AGE_CODE)
LEFT JOIN (SELECT SUM(TARGET_POP) AS X, AGE_CODE FROM SLEEP_TIME_DTL
    WHERE TIME_CODE=160 GROUP BY AGE_CODE) AS E USING(AGE_CODE)
LEFT JOIN (SELECT SUM(TARGET_POP) AS X, AGE_CODE FROM SLEEP_TIME_DTL
    WHERE TIME_CODE=170 GROUP BY AGE_CODE) AS F USING(AGE_CODE)
LEFT JOIN (SELECT SUM(TARGET_POP) AS X, AGE_CODE FROM SLEEP_TIME_DTL
    WHERE TIME_CODE=180 GROUP BY AGE_CODE) AS G USING(AGE_CODE)
WHERE A.X IS NOT NULL
OR B.X IS NOT NULL
OR C.X IS NOT NULL
OR D.X IS NOT NULL
OR E.X IS NOT NULL
OR F.X IS NOT NULL
OR G.X IS NOT NULL
提出情報
提出日時2022/07/04 18:12:32
コンテスト練習用コンテスト
問題年齢別睡眠時間分析
受験者paruki
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量80 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
80 MB
データパターン2
AC
78 MB