简体   繁体   中英

How to filter SQL query by using SSRS Yes or No Parameter

How to pass Yes or No parameter to SQL Query in SSRS. I have set @MyParam Values to 1 and 0. If parameter "Yes" should include the result with types "Direct" with others. If "No" Then result should be without "Direct" with others.

Help would be immensely appreciated as usual! :)

My Query:

SELECT EQ_WO_ID, EQ_WO_ID, job_type FROM EQ
WHERE ((@MyParam = 1 and job_type='Direct') or (@MyParam = 0 and job_type not null))

The logic you describe is:

WHERE ((@MyParam = 1) or
       (@MyParam = 0 and job_type <> 'Direct')
      )

If job_type can be NULL , you need to take that into account for the 0 condition.

Just another option. (my read is contains DIRECT or not).

MyParam can be a BIT or INT

 ....   
 Where sign(patindex('%Direct%',job_type))=@MyParam

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM