SSRS - change like to an exact match

I am trying to change an SSRS report so that the PROJECT parameter needs to be an exact match or if left blank returns all.

WHERE (V_WO.CCN=:CCN) AND (V_WO.MAS_LOC=:ML) AND (V_WO.STATUS <>'C') AND (V_WO.ORD_QTY-V_WO.COMPLETE_QTY>=0) AND (V_WO.MFG_CLOSE_DATE Is Null OR V_WO.FIN_CLOSE_DATE Is Null) AND (A.CUSTOMER LIKE '%'||:CUST||'%' OR A.CUSTOMER IS NULL) AND C.RN=1 AND ((:DUE ='LATE') AND (CASE WHEN(A.PO_DATE2 is NULL) THEN(SYSDATE) ELSE(A.PO_DATE2) END-V_WO.DUE_DATE<0) OR (:DUE='ANY')) AND (TRIM(V_WO.WO_NUM||'-'||V_WO.WO_LINE) LIKE '%'||:ORD_NUM||'%') AND (' '||A.PROJECT LIKE '%'||:PROJECT||'%') AND (A.QTY<>0 or A.QTY IS NULL)
slmcOperations ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewIT / Software Engineering ConsultantCommented:
Change:

AND (' '||A.PROJECT LIKE '%'||:PROJECT||'%')

to:

AND (A.PROJECT=:PROJECT OR A.PROJECT='')

Note that this won't handle NULL values for that column, I assumed that when you said "blank" you meant an empty string.


»bp
slmcOperations ManagerAuthor Commented:
Sorry.  Yes I do mean null values.  This works for everything but that now.
Bill PrewIT / Software Engineering ConsultantCommented:
Okay, how about:

AND (A.PROJECT=:PROJECT OR A.PROJECT='' OR A.PROJECT IS NULL) 

Open in new window


»bp
Announcing the Winners!

The results are in for the 15th Annual Expert Awards! Congratulations to the winners, and thank you to everyone who participated in the nominations. We are so grateful for the valuable contributions experts make on a daily basis. Click to read more about this year’s recipients!

slmcOperations ManagerAuthor Commented:
When I put this in and leave the PROJECT parameter blank the only returns I get are the nulls.

WHERE (V_WO.CCN=:CCN) AND (V_WO.MAS_LOC=:ML) AND (V_WO.STATUS <>'C') AND (V_WO.ORD_QTY-V_WO.COMPLETE_QTY>=0) AND (V_WO.MFG_CLOSE_DATE Is Null OR V_WO.FIN_CLOSE_DATE Is Null) AND (A.CUSTOMER LIKE '%'||:CUST||'%' OR A.CUSTOMER IS NULL) AND C.RN=1 AND ((:DUE ='LATE') AND (CASE WHEN(A.PO_DATE2 is NULL) THEN(SYSDATE) ELSE(A.PO_DATE2) END-V_WO.DUE_DATE<0) OR (:DUE='ANY')) AND (TRIM(V_WO.WO_NUM||'-'||V_WO.WO_LINE) LIKE '%'||:ORD_NUM||'%') AND (A.PROJECT=:PROJECT OR A.PROJECT=' ' OR A.PROJECT IS NULL) AND (A.QTY<>0 or A.QTY IS NULL)
Bill PrewIT / Software Engineering ConsultantCommented:
Oh, maybe I'm thinking about this backwards.  What you really want I think is "if a Project parameter is entered then only show exact matches to that Project, but if no Project is entered then show all Projects".  If so then it might be more like this, although I can't recall the proper way to check for a "blank" parameter, you may not need to check it both for an empty string and NULL, you may only need one of those...

AND (A.PROJECT=:PROJECT OR :PROJECT='' OR :PROJECT IS NULL) 

Open in new window


»bp

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
slmcOperations ManagerAuthor Commented:
That is exactly what I am looking for.  Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SSRS

From novice to tech pro — start learning today.