Multiple where requirements

I'm trying to first, exclude descriptions that contains "exciter", which currently works. Then, I only want to see "governor" and "fuel control" units if they are over 5.49 days from start date. I want to see everything else if it is over 2.49 days from start date. The code below is still showing "governors" and "fuel controls", even if they are over 2.49 days from start date. Please help.

where WH.DOC_STATUS <10 and
wh.wo_status = 'K030' and
wh.DESCRIPTN NOT LIKE '%EXCITER%' AND
((datediff(day, ws.START_DATE,GETDATE()) >5.49 AND WH.DESCRIPTN LIKE '%GOVERNOR%') OR
(datediff(day, ws.START_DATE,GETDATE()) >5.49 AND WH.DESCRIPTN LIKE '%FUEL CONTROL%') OR
(datediff(day, ws.START_DATE,GETDATE()) >2.49 AND NOT WH.DESCRIPTN LIKE '%GOVERNOR%') OR
(datediff(day, ws.START_DATE,GETDATE()) >2.49 AND NOT WH.DESCRIPTN LIKE '%FUEL CONTROL%'))

Try putting the two AND NOT within the same set of parenthesis. Like this:

where WH.DOC_STATUS <10 and
wh.wo_status = 'K030' and
wh.DESCRIPTN NOT LIKE '%EXCITER%' AND
((datediff(day, ws.START_DATE,GETDATE()) >5.49 AND WH.DESCRIPTN LIKE '%GOVERNOR%') OR
(datediff(day, ws.START_DATE,GETDATE()) >5.49 AND WH.DESCRIPTN LIKE '%FUEL CONTROL%') OR
(datediff(day, ws.START_DATE,GETDATE()) >2.49 AND NOT WH.DESCRIPTN LIKE '%GOVERNOR%' OR datediff(day, ws.START_DATE,GETDATE()) >2.49 AND NOT WH.DESCRIPTN LIKE '%FUEL CONTROL%')

EDIT: Or you can try eliminating the second AND NOT and putting just the second condition along with the first, like:

OR (datediff(day, ws.START_DATE,GETDATE()) >2.49 AND NOT (WH.DESCRIPTN LIKE '%GOVERNOR%' OR WH.DESCRIPTN LIKE '%FUEL CONTROL%')
1 Like

The second one worked perfect. Thank You!!

Glad I could help!