ソースコード
SELECT
  DATA.ORDER_DATE,
  DATA.MEMBER_CODE AS CODE,
  CASE DATA.OPTOUT_TYPE WHEN 0 THEN '可' WHEN 1 THEN '不可' ELSE '不明' END AS OPTOUT
FROM
(SELECT
  EO.MEMBER_CODE,
  MIN(EO.ORDER_DATETIME) AS ORDER_DATE,
  MM.OPTOUT_TYPE
FROM
  EC_ORDERS AS EO
INNER JOIN MEMBER_MST AS MM
  ON MM.MEMBER_CODE = EO.MEMBER_CODE
WHERE
  DATE(EO.ORDER_DATETIME) BETWEEN '2023-07-01' AND '2023-07-31'
GROUP BY
  EO.MEMBER_CODE) AS DATA
WHERE 
DATE(DATA.ORDER_DATE, '-1 YEARS') >
(SELECT
   DATE(ORDER_DATETIME)
FROM
  EC_ORDERS AS EC
WHERE  EC.MEMBER_CODE = DATA.MEMBER_CODE AND ORDER_DATETIME < DATA.ORDER_DATE
ORDER BY ORDER_DATETIME DESC
LIMIT 1)
ORDER BY DATA.ORDER_DATE DESC, DATA.MEMBER_CODE DESC
提出情報
提出日時2023/10/16 00:51:34
コンテスト第9回 SQLコンテスト
問題クーポン配布対象
受験者kamada
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量84 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
83 MB
データパターン2
AC
84 MB