Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query Question
Message
 
 
À
11/09/2004 14:08:42
James Blackburn
Qualty Design Systems, Inc.
Kuna, Idaho, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00941344
Message ID:
00941345
Vues:
9
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--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform