ソースコード
with pf as (
select PF_CODE,
(rank()over(order by TTL_SAL desc, CNT,  PF_CODE)-1) / 3 as GRP,
TTL_SAL,CNT
from (
select 
PF_CODE,
sum(case when KIND_CODE = 100 then TOTAL_VALUE else 0 end) as TTL_SAL,
sum(case when KIND_CODE = 150 then TOTAL_VALUE else 0 end) as CNT
from   CONVENIENCE
where SURVEY_YEAR = 2019
group by PF_CODE
)
)
select GRP+1 as NO, SUM(TTL_SAL) as TTL_SAL,
 round(cast(SUM(TTL_SAL) as real) * 100 /
 (select sum(TTL_SAL) from pf) , 1) 
 as PER_SAL,
 round(cast(((select sum(TTL_SAL) from pf where GRP <= main.GRP )) as real) * 100 /
 (select sum(TTL_SAL) from pf) , 1) 
 as CUM_SAL,
  (SUM(TTL_SAL) ) / sum(CNT) as AVG_SAL
from pf as main
group by GRP
;
提出情報
提出日時2024/04/28 19:16:20
コンテスト第9回 SQLコンテスト
問題販売額分析
受験者yunyun8686
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量87 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
87 MB
データパターン3
AC
86 MB