ソースコード
SELECT
    -- *
    LOGS.ORDER_DATETIME AS ORDER_DATE,
    LOGS.MEMBER_CODE AS CODE,
    CASE MEMBER_MST.OPTOUT_TYPE
        WHEN 0 THEN "可"
        WHEN 1 THEN "不可"
        ELSE "不明"
    END AS OPTOUT
FROM (
    SELECT
        MEMBER_CODE,
        MIN(ORDER_DATETIME) AS ORDER_DATETIME
    FROM
        EC_ORDERS
    WHERE
        ORDER_DATETIME >= "2023-07-01 00:00:00"
        AND ORDER_DATETIME < "2023-08-01 00:00:00"
    GROUP BY
        MEMBER_CODE
) AS LOGS
LEFT JOIN
    MEMBER_MST
ON
    LOGS.MEMBER_CODE = MEMBER_MST.MEMBER_CODE
LEFT JOIN (
    SELECT
        *
    FROM (
        SELECT
            ORDER_DATETIME,
            MEMBER_CODE,
            LAG(ORDER_DATETIME) OVER(PARTITION BY MEMBER_CODE ORDER BY ORDER_DATETIME ASC) AS PREV_ORDER_DATETIME
        FROM
            EC_ORDERS
    )
    WHERE
        PREV_ORDER_DATETIME IS NOT NULL
) AS PREV_LOGS
ON
    LOGS.MEMBER_CODE = PREV_LOGS.MEMBER_CODE
    AND LOGS.ORDER_DATETIME = PREV_LOGS.ORDER_DATETIME
WHERE
    PREV_LOGS.PREV_ORDER_DATETIME IS NOT NULL
    AND STRFTIME("%s", LOGS.ORDER_DATETIME) - STRFTIME("%s", PREV_LOGS.PREV_ORDER_DATETIME) > 365 * 24 * 60
 
ORDER BY
    LOGS.ORDER_DATETIME DESC,
    LOGS.MEMBER_CODE DESC
提出情報
提出日時2023/10/16 09:40:57
コンテスト第9回 SQLコンテスト
問題クーポン配布対象
受験者koya_346
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量90 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
90 MB
データパターン2
WA
86 MB