troubleshooting Question

How do I create an 'IF' function in a query rather than as an expression??

Avatar of erica686
erica686 asked on
Microsoft SQL ServerMicrosoft SQL Server 2005Microsoft Development
4 Comments1 Solution175 ViewsLast Modified:
I have created the following query:

SELECT MATTER_NO, BALANCE, WIP_TOLERANCE
FROM MATTER
WHERE (BALANCE>WIP_TOLERANCE)

I need the WIP_TOLERANCE to return '80' whenever the value is '0'. Whenever the value is not zero I want it to return that value. (EG if WIP_TOLERANCE is 5, return 5, if WIP_TOLERANCE is 0, always return 80)

I know how to do this by creating an expression using the IIF function, however I need this to be written into the query as I also need it to be a part of the WHERE clause. (Ie WHERE BALANCE>WIP_TOLERANCE - I never want to be <0)

Any help asap would be fantastic!!!
Erica.

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros