ソースコード
with tbl7 as (
select
    min(ORDER_DATETIME) as ORDER_DATETIME
    ,min(date(ORDER_DATETIME)) as OD_DATE
    ,MEMBER_CODE
from
    EC_ORDERS
where
    date(ORDER_DATETIME) between date("2023-07-01") and date("2023-07-31")
group by
    MEMBER_CODE
)
,tbl0 as (
select
    max(date(ORDER_DATETIME)) as OD_DATE
    ,MEMBER_CODE
from
    EC_ORDERS
where
    date(ORDER_DATETIME) < date("2023-07-01") 
group by
    MEMBER_CODE
)
,target as (
select
    tbl7.ORDER_DATETIME
    ,tbl7.MEMBER_CODE
from
    tbl7
    left join
    tbl0
    on tbl7.MEMBER_CODE = tbl0.MEMBER_CODE
where
    date(tbl0.OD_DATE,"+1 year")<tbl7.OD_DATE
)
select
    ORDER_DATETIME as ORDER_DATE
    ,t.MEMBER_CODE as CODE
    ,case 
        when m.OPTOUT_TYPE ="0" then "可"
        when m.OPTOUT_TYPE ="1" then "不可"
        else "不明"
    end as OPTOUT
from
    target as t
    inner join
    MEMBER_MST as m
    on t.MEMBER_CODE= m.MEMBER_CODE
order by
    ORDER_DATETIME desc
    ,t.MEMBER_CODE desc
提出情報
提出日時2024/03/13 18:44:51
コンテスト第9回 SQLコンテスト
問題クーポン配布対象
受験者gP2fWnUzTL
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量83 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
83 MB
データパターン2
AC
83 MB