I have a database table as below.
Id 1 and 4 are old members and their data is updated (as seen in updated date column).
Id 2 and 3 new members.
So now how we can query in SQL Server and get list of members updated/registered for a given date range?
Advertisement
Answer
coalesce()
would be a good fit here. If [updated date]
is NULL
, it will then look at [registration date]
select * from yourtable where coalesce([updated date],[registration date]) between '2021-01-01' and '2021-01-05'