I need to be able to do an IF ELSE in the having clause of a select statement. Here is an excerpt of what I am trying to do:
HAVING
IF @Vendor IS NOT NULL
THEN (COUNT(Iron_1.SN) > 0) AND [User].UserIdentifier = @Vendor AND Location_1.LocationName = @LocationName
ELSE
(COUNT(Iron_1.SN) > 0) AND Location_1.LocationName = @LocationName
I want certain filters based on if the user provided a value for a query parameter or not.