Question : Conditional where statement to include or exclude null values

I am trying to create a conditional where statement in a t-sql query to include or exclude a set of records based on whether a certain field is null or not. When I try to run the query I get the following error: Incorrect syntax near the keyword 'IS'. The query is quite long so I've included just the where statement.
Is it possible to build a conditional statement based on Null values and if so could someone please help me correct my mistake.
Thanks in advance.
Code Snippet:
1:
2:
3:
4:
5:
6:
WHERE     Case when (MOnth(Now) = 4) then (InvoicedAmountTBL_2.[Posting Date] IS NOT NULL OR
                      InvoicedAmountTBL_2.[Posting Date] IS NULL) and (dbo.[Gallowglass Live$Job Task].[Booking Status] = 0 OR
                      dbo.[Gallowglass Live$Job Task].[Booking Status] = 1 OR
                      dbo.[Gallowglass Live$Job Task].[Booking Status] = 2) else (InvoicedAmountTBL_2.[Posting Date] IS NOT NULL) and (dbo.[Gallowglass Live$Job Task].[Booking Status] = 0 OR
                      dbo.[Gallowglass Live$Job Task].[Booking Status] = 1 OR
                      dbo.[Gallowglass Live$Job Task].[Booking Status] = 2) end
Open in New Window Select All

Answer : Conditional where statement to include or exclude null values

Your use of case is not correct here.  You should be performing the logic in the Where clause like so:
1:
2:
3:
4:
5:
6:
7:
8:
9:
WHERE   ((MOnth(Now) = 4) and
         ((InvoicedAmountTBL_2.[Posting Date] IS NOT NULL OR
                      InvoicedAmountTBL_2.[Posting Date] IS NULL) and (dbo.[Gallowglass Live$Job Task].[Booking Status] = 0 OR
                      dbo.[Gallowglass Live$Job Task].[Booking Status] = 1 OR
                      dbo.[Gallowglass Live$Job Task].[Booking Status] = 2)))
	OR ((MOnth(Now) <> 4) and
		 ((InvoicedAmountTBL_2.[Posting Date] IS NOT NULL) and (dbo.[Gallowglass Live$Job Task].[Booking Status] = 0 OR
                      dbo.[Gallowglass Live$Job Task].[Booking Status] = 1 OR
                      dbo.[Gallowglass Live$Job Task].[Booking Status] = 2)))
Open in New Window Select All
Random Solutions  
 
programming4us programming4us