ソースコード
WITH SAL_TBL AS 
(
    SELECT
        ((ROW_NUMBER() OVER w) + 2) / 3 AS NO, 
        A.PF_CODE AS PF_CODE,
        A.TOTAL_VALUE AS SAL,
        B.TOTAL_VALUE AS SHOP
    FROM 
    (SELECT * FROM CONVENIENCE WHERE KIND_CODE = '100' AND SURVEY_YEAR = '2019') AS A
    INNER JOIN
    (SELECT * FROM CONVENIENCE WHERE KIND_CODE = '150' AND SURVEY_YEAR = '2019') AS B
    ON A.PF_CODE = B.PF_CODE
    WINDOW w AS (ORDER BY A.TOTAL_VALUE DESC, B.TOTAL_VALUE ASC, A.PF_CODE ASC)
    ORDER BY NO
),
PF_SAL AS 
(
    SELECT 
        NO,
        SUM(SAL) AS TTL_SAL, 
        SUM(SAL) / SUM(SHOP) AS AVG_SAL 
    FROM SAL_TBL
    GROUP BY NO
)
SELECT
    NO,
    TTL_SAL,
    ROUND(100.0 * TTL_SAL / (SUM(TTL_SAL) OVER ()), 1) AS PER_SAL,
    ROUND(100.0 * SUM(TTL_SAL) OVER w / (SUM(TTL_SAL) OVER ()), 1) AS CUM_SAL,
    AVG_SAL
    FROM PF_SAL
    WINDOW w AS (
        ORDER BY NO
    )
    
提出情報
提出日時2023/12/14 10:36:17
コンテスト第9回 SQLコンテスト
問題販売額分析
受験者nadia
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
85 MB
データパターン3
AC
84 MB