ソースコード
SELECT
  C.CUST_CODE AS "CODE"
  , CUST_NAME AS "NAME"
  , COUNT(ORDER_NO) AS "CNT"
  , SUM(ORDER_AMNT) AS "TTL_AMT"
  , ROUND( 
    cast(SUM(ORDER_AMNT) as REAL) / cast(COUNT(ORDER_NO) as REAL)
    , 0
  ) AS "AVG_AMT" 
FROM
  ORDERS AS O 
  INNER JOIN CUSTOMER AS C 
    ON O.CUST_CODE = C.CUST_CODE 
WHERE
  ORDER_DATE >= "2023-09-01" 
  AND ORDER_DATE <= "2023-09-30" 
GROUP BY
  C.CUST_CODE 
HAVING
  COUNT(ORDER_NO) >= 5 
ORDER BY
  COUNT(ORDER_NO) DESC
  , AVG_AMT DESC
  , CODE ASC 
LIMIT
  5;
提出情報
提出日時2023/12/18 10:02:40
コンテスト第10回 SQLコンテスト
問題優良顧客
受験者nagata
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量99 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
99 MB
データパターン2
AC
99 MB