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--