I am attempting to create a query that will show users who have not logged on in the past 30 days. The way I can do this is by using my 3 Separate WIP tables. I want to display the out put where USER is not in WIP and WIP7Hist but only in WIP30Hist Here is is what I have written in an attempt to do the is:
Select Distinct wc.UserID
, CONVERT(Datetime,wc.ShiftDate) as TimeDate
From WIP30Hist wc With(nolock)
Join WIP wa with(nolock) on wc.USerID = wa.UserID
Join WIP7Hist wb with(nolock) on wc.UserID = wa.UserID
Where wc.TimeDate <= GETDATE()-30 and wc.UserID Not in(select wa.UserID from WIP)
and wc.UserID Not in(select wb.UserID from WIP7Hist)
Group By wc.UserID, wc.TimeDate, wc.ShiftDate
Order By TimeDate