ソースコード
with HAN as (
    SELECT PF_CODE, SUM(TOTAL_VALUE) HV
    FROM CONVENIENCE
    WHERE SURVEY_YEAR = 2019 AND KIND_CODE = '100'
    GROUP BY PF_CODE
), TEN as (
    SELECT PF_CODE, SUM(TOTAL_VALUE) TV
    FROM CONVENIENCE
    WHERE SURVEY_YEAR = 2019 AND KIND_CODE = '150'
    GROUP BY PF_CODE
), T as (
    SELECT H.PF_CODE, H.HV, T.TV, row_number() over (order by H.HV desc, T.TV, H.PF_CODE) rank
    FROM HAN H JOIN TEN T ON H.PF_CODE = T.PF_CODE
), T2 as (
    SELECT PF_CODE, HV, TV, ((rank - 1) / 3) + 1 GR
    FROM T
), AllT as (
    SELECT SUM(HV) TOTAL_HV
    FROM HAN
), S as (
    SELECT
      GR,
      SUM(HV) TTL_SAL,
      round(SUM(HV) * 100.0 / AllT.TOTAL_HV, 1) PER_SAL,
      round((SELECT SUM(TMP.HV) FROM T2 TMP WHERE TMP.GR <= T2.GR) * 100.0 / AllT.TOTAL_HV, 1) CUM_SAL,
      round(SUM(HV) / SUM(TV), 0) AVG_SAL
    FROM T2, AllT
    GROUP BY GR
)

SELECT *
FROM S
ORDER BY 1
提出情報
提出日時2023/10/14 13:07:08
コンテスト第9回 SQLコンテスト
問題販売額分析
受験者mine
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量78 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
78 MB
データパターン2
WA
77 MB
データパターン3
WA
77 MB