SQLTeam.com | Weblogs | Forums

Exclude rows for multiple combined conditions

Hi Everyone,

I am stuck on a SQL query where I need to exclude rows in the dataset only when All the 3 combined conditions below are met-

Off in ('UAE', 'DXB') and
Datepart(weekday, workdate) <> 5 and
workdate < '2021-12-12'

I am using the And operator but it still excludes rows in the dataset if any of the above conditions are met which I don't want.

Thanks for your kind help.

You'll need a GROUP BY to do this (if you need to, you can use the results of the GROUP BYed query to requery the original table).

To do that, we need to know what key column(s) you need to SELECT as part of the query. Maybe employee_id?

are there other filters in the where clause?

Many thanks for your replies. I used the below logic and its working as intended.

FROM ...
WHERE NOT (condition1 and condition2 and condition3)