ソースコード
with 
EC_O_LAG as (
select
    ORDER_NO
    ,MEMBER_CODE
    ,ORDER_DATETIME
    ,lag(ORDER_DATETIME) over (partition by MEMBER_CODE 
    order by ORDER_DATETIME)
    as PREV_DT
from 
    EC_ORDERS
)
,TMP1 as (
select
    ORDER_NO as ORDER_NO_
    ,MEMBER_CODE as MEMBER_CODE_
    ,min(ORDER_DATETIME) as DT2307
from 
    EC_ORDERS
where
    date(ORDER_DATETIME) between '2023-07-01' and '2023-07-31'
group by 1,2
)
,TMP2 as (
select
    ORDER_NO
    ,MEMBER_CODE
    ,ORDER_DATETIME
    ,PREV_DT
from EC_O_LAG
    inner join TMP1
    on ORDER_NO = ORDER_NO_
        and MEMBER_CODE_ = MEMBER_CODE
where
    strftime('%s', date(ORDER_DATETIME)) - strftime('%s', date(PREV_DT)) >365*24*60*60 
)

select
    T.ORDER_DATETIME
    ,T.MEMBER_CODE as CODE 
    ,case
        when OPTOUT_TYPE=0 then '可'
        when OPTOUT_TYPE=1 then '不可'
        else '不明' end as OPTOUT
from 
    TMP2 T
    left outer join 
        MEMBER_MST M
        on T.member_code = M.member_code
order by 1 desc, 2 desc
提出情報
提出日時2024/02/18 11:15:43
コンテスト第9回 SQLコンテスト
問題クーポン配布対象
受験者1120011
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
85 MB
データパターン2
WA
85 MB