troubleshooting Question

Need help with a Where clause in SQL Server query

Avatar of Mike Orther
Mike OrtherFlag for United States of America asked on
Microsoft SQL ServerSQL* system SQL queries
9 Comments4 Solutions20 ViewsLast Modified:
I have a SQL Query where I need to limit the results set.  I know the WHERE statement is incorrect, but gives an idea what I am looking for.  I tried doing this in a CASE statement but I just could not get it.  I am hoping someone can help me with this.

SELECT        TOP (100) PERCENT dbo.WO010032.ITEMNMBR AS [Make Item], dbo.PK010033.ITEMNMBR AS [Item No], dbo.PK010033.QTY_ALLOWED_I AS PickQty, dbo.IV00300.BIN
FROM            dbo.WO010032 RIGHT OUTER JOIN
                         dbo.PK010033 ON dbo.WO010032.MANUFACTUREORDER_I = dbo.PK010033.MANUFACTUREORDER_I LEFT OUTER JOIN
                         dbo.IV00101 ON dbo.PK010033.ITEMNMBR = dbo.IV00101.ITEMNMBR LEFT OUTER JOIN
                         dbo.IV00300 ON dbo.PK010033.ITEMNMBR = dbo.IV00300.ITEMNMBR AND dbo.PK010033.LOCNCODE = dbo.IV00300.LOCNCODE

WHERE      IF dbo.WO010032.ITEMNMBR LIKE '60%' THEN dbo.IV00300.BIN NOT LIKE 'MFG%'
                   ELSE dbo.IV00300.BIN NOT LIKE 'BUF%'
Join our community to see this answer!
Unlock 4 Answers and 9 Comments.
Start Free Trial
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 4 Answers and 9 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