Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query Question
Message
De
11/09/2004 18:39:52
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:
00941388
Vues:
10
Thanks Sergey,

Your second answer worked because I have a potential of having more than one row due to multiple suppliers.


>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.
>>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform