ソースコード
SELECT
    ITEM_CODE AS CODE,
    ITEM_NAME AS NAME,
    SAL_ITEM,
    CML_AMT,
    ROUND(100.0 * SAL_ITEM / TOTAL_AMT, 1) || '%' AS SAL_COMP,
    ROUND(100.0 * CML_AMT / TOTAL_AMT, 1) || '%' AS TTL_COMP,
    CASE 
        WHEN ROUND(100.0 * CML_AMT / TOTAL_AMT, 1) <= 40.0 THEN 'A'
        WHEN ROUND(100.0 * CML_AMT / TOTAL_AMT, 1) <= 80.0 THEN 'B'
        ELSE 'C'
    END AS RANK
FROM (
    SELECT
        ITEM_CODE,
        SAL_ITEM,
        SUM(SAL_ITEM) OVER (ROWS UNBOUNDED PRECEDING) AS CML_AMT,
        SUM(SAL_ITEM) OVER () AS TOTAL_AMT
    FROM (
        SELECT
            ITEM_CODE,
            SUM(UNITPRICE * SALES_QTY) AS SAL_ITEM
        FROM (
            SELECT
                *
            FROM
                SALES
            WHERE
                SALES_DATE BETWEEN '2023-06-01' AND '2023-06-30'
        )
        INNER JOIN
            SALES_DTL USING (SALES_NO)
        GROUP BY
            ITEM_CODE
        ORDER BY
            SAL_ITEM DESC,
            ITEM_CODE DESC
    )
)
INNER JOIN
    ITEM USING (ITEM_CODE)
;
提出情報
提出日時2023/08/23 14:49:09
コンテスト第7回 SQLコンテスト
問題ABC分析
受験者naku6aru
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量78 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
76 MB
データパターン2
WA
77 MB
データパターン3
WA
78 MB