I have a mapping table that contains: Start_Dt and End_Dt.
I have a table that has Member_ID and Received_Dt.
What I want to do is set a flag based on whether or not the Received Dt is between the Start_Dt and END Dt.
I don't have a primary key so I'm not sure the most effective place to start.
select
Z.Member_ID,
Z.Received_Dt,
FLAG=CASE WHEN A.Received_Date between W.ST_DT AND W.END_DT THEN 'Yes' ELSE NULL END
from #Member Z
left join dbo.Weeks W
Very ill-defined question but I guess you need something like:
update member b set flag = (
select case when count(*) > 0 then 'y' else 'n' end
from mapping m
where b.received_dt >= m.start_dt
and b.received_dt <= m.end_dt
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.