Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL TOP in Query
Message
De
16/02/2009 14:56:51
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Database:
Visual FoxPro
Divers
Thread ID:
01382151
Message ID:
01382183
Vues:
41
Thanks Sergey,

that's the same solution Naomi provided which works (now I just need to adjust all the rest of my code to fit in an INNER JOIN nistead of a WHERE).


>
>SELECT c_Test.*;
>	FROM c_Test ;
>	WHERE iSaleid in ( ;
>			SELECT isaleid FROM (SELECT TOP 2 isaleid, PADL(TRIM(cInvoiceNo),11) AS SortOrder ;
>						FROM c_Test ORDER BY SortOrder desc) dt1)
>
>>
>>SET ANSI ON apparently does not affect the result. Here's the code I'm trying:
>>
>>
CREATE CURSOR c_Test;
>>(iSaleid i,;
>>cInvoiceNo c(11),;
>>cDesc C(10))
>>
>>FOR i = 1 TO 11
>>	INSERT INTO c_Test (iSaleid, cInvoiceNo, cDesc) VALUES (i, TRANSFORM(i), TRANSFORM(i))
>>ENDFOR
>>
>>SET ANSI ON
>>
>>SELECT c_Test.*;
>>	FROM c_Test ;
>>	WHERE iSaleid in (SELECT TOP 2 isaleid FROM c_Test ORDER BY cInvoiceNo desc)
>>
>>SET ANSI OFF
>>
>>SELECT c_Test.*;
>>	FROM c_Test ;
>>	WHERE iSaleid in (SELECT TOP 2 isaleid FROM c_Test ORDER BY cInvoiceNo desc)
>>
>>my result has 8 and 9, not 10 and 11.
>>
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform