ソースコード
with tmp as(
select PF_CODE,
sum(case KIND_CODE when 100 then TOTAL_VALUE else 0 end) as sum1,
sum(case KIND_CODE when 150 then TOTAL_VALUE else 0 end) as sum2
  from CONVENIENCE
 where SURVEY_YEAR = 2019
group by PF_CODE),
tmp2 as(
select PF_CODE,sum1,sum2,
Row_Number() over(order by sum1 desc,sum2,PF_CODE) as rn,
sum(sum1) over() as sum3
  from tmp)
select Row_Number() over(order by (rn-1) / 3) as NO,
sum(sum1) as TTL_SAL,
round(cast(sum(sum1) as REAL)
     /cast(sum3 as REAL)
     * 100 , 1) as PER_SAL,
round(cast(sum(sum(sum1)) over(order by (rn-1) / 3) as REAL)
     /cast(sum3 as REAL)
     * 100 , 1) as CUM_SAL,
sum(sum1)/sum(sum2) as AVG_SAL
  from tmp2
 where rn <= 30
group by (rn-1) / 3,sum3
order by NO
提出情報
提出日時2023/10/13 22:33:32
コンテスト第9回 SQLコンテスト
問題販売額分析
受験者AketiJyuuzou
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量79 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
78 MB
データパターン2
AC
79 MB
データパターン3
AC
79 MB