I'm trying to write a SQL query which will be used in an SSRS report. It is to show the number of changes made to a table by a user between two dates. I have the query working fine except when I try to remove all entries by a certain user on a certain day as these were done to cleanse the data and will skew the values.
The WHERE clause I have tried is as follows:
WHERE
(DATEADD(MONTH, DATEDIFF(MONTH, 0, Hist.Timestamp), 0) >= @FromDate)
AND
(DATEADD(MONTH, DATEDIFF(MONTH, 0, Hist.Timestamp), 0) < @ToDate)
AND
(Hist.Timestamp <> '2022-04-26' AND Hist.UserId <> 'DOMAIN\John.Smith')
But this removes all entries by that user and not just entries by that user on that day.
How can I edit this WHERE clause to to exclude the results which are for both items?
Thanks, Paul
CodePudding user response:
...AND NOT (hist.timestamp = '2022-04-26' AND hist.userid = 'DOMAIN\John.Smith')