ソースコード
WITH A AS (
    SELECT 
        CUST_CODE,
        COUNT(CUST_CODE) AS COUNT
    FROM
        ORDERS
    WHERE
        DATE(ORDER_DATE) BETWEEN DATE('2023-09-01') AND DATE('2023-09-30')
    GROUP BY
        CUST_CODE
)
SELECT
    ORDERS.CUST_CODE AS CODE,
    CUSTOMER.CUST_NAME AS NAME,
    COUNT(*) AS CNT,
    SUM(ORDERS.ORDER_AMNT) AS TTL_AMT,
    ROUND(CAST(SUM(ORDERS.ORDER_AMNT) AS float) / COUNT(*), 0) AS AVG_AMT
FROM
    ORDERS
JOIN
    CUSTOMER USING(CUST_CODE)
JOIN
    A USING(CUST_CODE)
WHERE
    DATE(ORDER_DATE) BETWEEN DATE('2023-09-01') AND DATE('2023-09-30') AND
    A.COUNT >= 5
GROUP BY
    ORDERS.CUST_CODE
ORDER BY
    CNT DESC,
    AVG_AMT DESC,
    CODE
;
提出情報
提出日時2023/12/18 09:12:01
コンテスト第10回 SQLコンテスト
問題優良顧客
受験者sepia
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
WA
84 MB