I could really use some help / advice on this. I have 4 parameters:
1) DATE
2) Hashtag
3) Make
4) Model
I am trying to build a query where its possible for the user to leave either Hashtag, Make, or Model parameter as null (Date parameter is required and can not be left null)
For example:
If the user selects 05/25/2017 as "DATE" parameter, leaves "Hashtag" parameter blank, "Make" parameter as "honda", and "Model" parameter as "civic",
The reports would: 1) filter the date field for 05/25/2017, 2) filter the "Make" field for "honda", 3) filter the "Model" field for "civic". (Since the user left the "Hashtag" parameter NULL, the report would not filter for anything on the "Hashtag" field)
How can I write the WHERE clause so that if the user leaves a certain parameter blank (except "DATE"), the query will skip filtering for that parameter and move on to the next one?
Something along the lines of:
WHERE Opened_Time = @DATE
AND ( IFF @Hashtag IS NOT NULL THEN HASHTAG_ID = @Hashtag
ELSE IFF @Make IS NOT NULL THEN MAKE_ID = @Make
ELSE IFF @Model IS NOT NULL THEN MODEL_ID = @Model
ELSE dont do anything? )
I realize the IFF part is no where near correct, I just wanted to try and explain what I want the report to do.
Does this make sense? Any help would be greatly appreciated!!