Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Query Question
Message
 
 
To
11/09/2004 14:08:42
James Blackburn
Qualty Design Systems, Inc.
Kuna, Idaho, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00941344
Message ID:
00941345
Views:
10
Hi James,

If Sybase supports TOP clause, following query should work.
SELECT TOP 1 * FROM PriceList 
  WHERE PoductID = < ProductId >
    AND ListQty <= < Sold Qty >
  ORDER BY ListQty DESC

--Otherwise try

SELECT * FROM PriceList 
  WHERE PoductID = < ProductId >
    AND ListQty = (SELECT MAX(ListQty) FROM PriceList 
			  WHERE PoductID = < ProductId >
    			AND ListQty <= < Sold Qty >)
>
>
>I have a SQL question which seems to be simple but I can’t seem get it to work. I am using Sybase ASA, not FoxPro. I have a list of price levels based on quantity. For example, 100 items sell for 2.00 250 items sell for 1.50 and 500 items sell for 1.00. I need a query to find the proper line based on the quantity being purchased. For example, if 400 items were being purchased then I need to get the 250 qty price.
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform