SQLTeam.com | Weblogs | Forums

SQL where clause logic for report


In the report I am working on there are 2 parameters - the first is a drop down list showing countries and other one is a user entry textbox.

The requirement is to show the matching data based on the country and the value entered in the textbox.

however, if no value is selected from the drop down list then it is mandatory for the user to enter value in the textbox and then the data should be displayed on the report as per the user entered value.

Also, if only the country is selected and no user value is entered, then all the data for the particular country should be displayed.

I am not sure how to code this requirement within the where clause in SQL.

I have tried something like below but it doesnt work.

AND (OFFC_CODE IN (@office) and FOLDER_NUM IN (@fol_num)

OR OFFC_CODE IN (@office) OR FOLDER_NUM IN (@fol_num))

Can somebody please help on this ?


I've found this for you:

Empty multi-value parameter (microsoft.com)

I would use the answer to filter on the report and not in de query but it depends on the amount of data.

Thanks very much for your reply. It was really helpful.