Solved

correct syntax for greater than in WHEN clause

Posted on 2013-05-29
3
238 Views
Last Modified: 2013-05-29
Can't get this to work. Any ideas where my syntax is wrong here?

Case cod.Quantity WHEN < 5 THEN 0 WHEN < 10 THEN 0.05 ELSE 0.1 END AS VolumeDiscount

Open in new window


full statement
SELECT     cod.OrderDetailsID, cod.OrderID, cod.DeliveryDateRequest, cod.GrowthStageID, cod.StandingOrder, cod.Comments, cod.Quantity, cod.ClientSpecialDiscount, 
                      cod.ResellerSpecialDiscount, cod.ProductID, 
                      CASE cod.GrowthStageID WHEN 3 THEN p.ProductPrice - 2 WHEN 2 THEN p.ProductPrice - 1 ELSE p.ProductPrice END AS ProductPrice
,Case cod.Quantity WHEN < 5 THEN 0 WHEN < 10 THEN 0.05 ELSE 0.1 END AS VolumeDiscount
FROM         WW.ClientOrderDetails AS cod INNER JOIN
                      WW.Products AS p ON cod.ProductID = p.ProductID INNER JOIN
                      WW.TaxCategories AS tc ON p.TaxCategoryID = tc.TaxCategoryID INNER JOIN
                      WW.ClientOrders AS co ON cod.OrderID = co.OrderID INNER JOIN
                      WW.PaymentOptions AS po ON co.PaymentOptionID = po.PaymentOptionID
WHERE     (cod.OrderID = 401001)

Open in new window

0
Comment
Question by:Shawn
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
gt2847c earned 500 total points
ID: 39206012
Try it as:
CASE WHEN cod.Quantity < 5 THEN 0
     WHEN cod.Quantity < 10 THEN 0.05
     ELSE 0.1 END AS [VolumeDiscount]

Open in new window

0
 
LVL 1

Author Comment

by:Shawn
ID: 39206031
perfect, thank you. one more question...posting now
0
 
LVL 1

Author Comment

by:Shawn
ID: 39206045
here's the new question Q_28142325
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question