ソースコード
select
    sub.CCODE as CODE
    ,sub.CNAME as NAME
    ,sub.OCNT as CNT
    ,sub.OAMNT as TTL_AMT
    ,sub.OAVGAMNT as AVG_AMT
from
    (
        select
            c.cust_code as CCODE
            ,c.cust_name as CNAME
            ,count(o.ORDER_NO) as OCNT
            ,sum(o.ORDER_AMNT) as OAMNT
            ,round(avg(o.ORDER_AMNT), 0) as OAVGAMNT
        from
            orders as o
            inner join customer as c
                on c.cust_code = o.cust_code                
        where
            date(o.order_date) between date('2023-09-01') and date('2023-09-30')
        group by
            c.cust_code
            having
                OCNT >= 5
    ) as sub
group by CODE
order by
    CNT desc
    ,AVG_AMT desc
    ,CODE asc
limit 5
;
    
提出情報
提出日時2024/12/02 18:27:40
コンテスト第10回 SQLコンテスト
問題優良顧客
受験者takey
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量105 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
105 MB
データパターン2
AC
28 MB