ソースコード
select * from
(
select a."AGE_CODE" as "年齢コード",
a."AGE_NAME" as "年齢階層名",
(select sum(c."SP_TIME_5") from "SLEEP_TIME_DTL" as c where c."PF_CODE" in ('01000','02000','03000','04000','07000') and c."AGE_CODE" = a."AGE_CODE") as "5時間未満",
(select sum(c."SP_TIME_6") from "SLEEP_TIME_DTL" as c where c."PF_CODE" in ('01000','02000','03000','04000','07000') and c."AGE_CODE" = a."AGE_CODE") as "5時間以上6時間未満",
(select sum(c."SP_TIME_7") from "SLEEP_TIME_DTL" as c where c."PF_CODE" in ('01000','02000','03000','04000','07000') and c."AGE_CODE" = a."AGE_CODE") as "6時間以上7時間未満",
(select sum(c."SP_TIME_8") from "SLEEP_TIME_DTL" as c where c."PF_CODE" in ('01000','02000','03000','04000','07000') and c."AGE_CODE" = a."AGE_CODE") as "7時間以上8時間未満",
(select sum(c."SP_TIME_9") from "SLEEP_TIME_DTL" as c where c."PF_CODE" in ('01000','02000','03000','04000','07000') and c."AGE_CODE" = a."AGE_CODE") as "8時間以上9時間未満",
(select sum(c."SP_TIME_9OVER") from "SLEEP_TIME_DTL" as c where c."PF_CODE" in ('01000','02000','03000','04000','07000') and c."AGE_CODE" = a."AGE_CODE") as "9時間以上"
from "AGE_GRP" as a
) as tmp
where tmp."5時間未満" is not null
and tmp."5時間以上6時間未満" is not null
and tmp."6時間以上7時間未満" is not null
and tmp."5時間以上6時間未満" is not null
and tmp."7時間以上8時間未満" is not null
and tmp."8時間以上9時間未満" is not null
and tmp."9時間以上" is not null
order by "年齢コード" asc
提出情報
提出日時2022/11/25 16:07:28
コンテスト第1回 SQLコンテスト
問題睡眠時間帯別集計
受験者hhxu
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
79 MB
データパターン2
AC
86 MB