Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Sql statement with Case not working

$
0
0

I'm not sure why this is not working.  It worked fine until I put in the second Case 

SELECT     OrderInfo.SerialNumber,customerid,case CustomerID when 'S325' then (Select b.region) else (Select CustomerId) end as region
FROM       OrderInfo INNER JOIN [SCP-SPP_Branches] b ON LEFT(OrderInfo.PoNumber, 2) = b.BranchNumber
WHERE     
case customerid 
when 'S325' then ((Orderinfo.OrderDate > '1/1/2013' AND (NOT (OrderInfo.SerialNumber LIKE N'WEB%')))
          else (OrderInfo.orderdate > '1/1/2012' and < '5/1/2013')
 end
ORDER BY OrderInfo.SerialNumber

I get the following error

Msg 170, Level 15, State 1, Line 5

Line 5: Incorrect syntax near '>'.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>