Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL TOP in Query
Message
 
 
To
16/02/2009 14:36:21
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01382151
Message ID:
01382172
Views:
49
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.
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform