I have wrote SQL to select user data for last three months, but I think at the moment it updates daily.
I want to change it so that as it is now October it will not count Octobers data but instead July's to September data and change to August to October when we move in to November
This is the SQL I got at the moment:
declare @Today datetime
declare @Category varchar(40)
set @Today = dbo.udf_DateOnly(GETDATE())
set @Category = 'Doctors active last three months updated'
declare @last3monthsnew datetime
set @last3monthsnew=dateadd(m,-3,dbo.udf_DateOnly(GETDATE()))
delete from LiveStatus_tbl where Category = @Category
select @Category, count(distinct U.userid)
from UserValidUKDoctor_vw U
WHERE LastLoggedIn >= @last3monthsnew
How would I edit this to do that?