ソースコード
with order_join AS (
    select *
    from customer c
    left outer join orders o
        on c.CUST_CODE = o.CUST_CODE
    where o.order_date >= '2023-09-01'
        AND o.order_date <= '2023-09-30'
    )
, order_count AS(
    select c.CUST_CODE
    from customer c
    left outer join orders o
        on c.CUST_CODE = o.CUST_CODE
    group by c.CUST_CODE
    having COUNT(1) >= 5
    )
select o.CUST_CODE AS CODE
    , CUST_NAME AS NAME
    , COUNT(1) AS CNT
    , SUM(ORDER_AMNT) AS TTL_AMT
    , round(CAST(SUM(ORDER_AMNT) AS DOUBLE) / CAST(COUNT(1) AS DOUBLE), 0) AS AVG_AMT
from order_join o
inner join order_count c
    on o.CUST_CODE = c.CUST_CODE
group by o.CUST_CODE, o.CUST_NAME
order by CNT desc
    , AVG_AMT desc
    , CODE;
提出情報
提出日時2023/12/17 22:27:44
コンテスト第10回 SQLコンテスト
問題優良顧客
受験者sql_yowayowa
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量91 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
86 MB
データパターン2
WA
91 MB