I am trying to put an if condition within a where clause and I cannot figure out the correct syntax for what I want.
The logic should be if a certain period is equal to a specific number then check to make sure pdftype is not null else then don't check it all.
Here's what I have so far:
where
g.ReportInstanceID = blah
and rcr.FormID = blah
and rcr.FormSectionID = blah
and rcr.SubSectionID = blah
and CASE rcr.DataCollectionPeriodID
WHEN 163 THEN (PDFType IS NOT NULL)
END
ORas shown in answer below, but you can useCASEinWHERE:AND CASE WHEN rcr.DataCollectionPeriodID = 163 THEN PDFType ELSE 'X' END IS NOT NULLCASEexpression can be used in aONclause. The same works for aWHEREclause.