ソースコード
WITH GROUPS AS (
SELECT
    (ROW_NUMBER() OVER(ORDER BY TOTAL_VALUE DESC) + 2) / 3 AS GROUP_NO,
    PF_CODE,
    TOTAL_VALUE AS SALES_AMT
FROM
    CONVENIENCE
WHERE
    SURVEY_YEAR = 2019
    AND KIND_CODE = 100
), STORES AS (
SELECT
    GROUPS.GROUP_NO AS GROUP_NO,
    SUM(CONVENIENCE.TOTAL_VALUE) AS STORE_SUM
FROM
    CONVENIENCE
INNER JOIN GROUPS USING(PF_CODE)
WHERE
    SURVEY_YEAR = 2019
    AND KIND_CODE = 150
GROUP BY 1
), SALES AS (
SELECT
    GROUP_NO,
    SUM(SALES_AMT) AS SALES_SUM
FROM
    GROUPS
GROUP BY 1
), TOTAL AS (
SELECT
    SUM(SALES_SUM) AS SALES_TTL
FROM
    SALES
)
SELECT
    A.GROUP_NO AS NO,
    A.SALES_SUM AS TTL_SAL,
    ROUND(100.0 * A.SALES_SUM / TOTAL.SALES_TTL, 1) AS PER_SAL,
    ROUND(100.0 * SUM(B.SALES_SUM) / TOTAL.SALES_TTL, 1) AS CUM_SAL,
    FLOOR(CAST(A.SALES_SUM AS REAL) / STORES.STORE_SUM) AS AVG_SAL
FROM SALES A, TOTAL
INNER JOIN SALES B ON (A.GROUP_NO >= B.GROUP_NO)
INNER JOIN STORES ON (A.GROUP_NO = STORES.GROUP_NO)
GROUP BY 1
ORDER BY 1
提出情報
提出日時2023/12/17 14:24:10
コンテスト第9回 SQLコンテスト
問題販売額分析
受験者hiffy12
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
2/3
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
84 MB
データパターン3
WA
85 MB