Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL: ORDER BY clause is invalid
Message
From
03/04/2005 18:01:53
 
 
To
02/04/2005 04:10:10
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Novell 5.x
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01000629
Message ID:
01001118
Views:
122
< snip >

>However,A simple example is this:
>
>CREATE CURSOR test (aa m)
>SELECT DISTINCT LEFT(AA,1) AS AA FROM TEST ORDER BY 1
>
>SELECT DISTINCT .t. AS AA FROM TEST ORDER BY AA
>
>CREATE CURSOR test (aa m)
>SELECT DISTINCT LEFT(AA,1) AS AA FROM TEST ORDER BY 1
>* BUG
>SELECT DISTINCT LEFT(AA,1) AS AA FROM TEST ORDER BY AA
>* if previous has not convinced to you, then
>SELECT DISTINCT .T. AS AA FROM TEST ORDER BY AA
>* DISTINCT is insignificant
>SELECT LEFT(AA,1) AS AA FROM TEST ORDER BY AA
>* more simple
>SELECT .T. AS AA FROM TEST ORDER BY AA
>* if not enough, then not there is hope
>
>
>Fabio


Fabio-

The problem with your examples is that your "AS" field is the same as the underlying field.
Try the following:
CREATE CURSOR test (aa m)

SELECT DISTINCT LEFT(AA,1) AS AB FROM TEST ORDER BY 1
* BUG
SELECT DISTINCT LEFT(AA,1) AS AB FROM TEST ORDER BY AB
* if previous has not convinced to you, then
SELECT DISTINCT .T. AS AB FROM TEST ORDER BY AB
* DISTINCT is insignificant
SELECT LEFT(AA,1) AS AB FROM TEST ORDER BY AB
* more simple
SELECT .T. AS AB FROM TEST ORDER BY AB
* if not enough, then not there is hope
Again I believe the error is not because of the "AS" clause as much as it is because it is a memo field.
CREATE CURSOR test (aa m)

SELECT DISTINCT LEFT(AA,1), AA AS AB FROM TEST ORDER BY 1,2
* or

SELECT DISTINCT LEFT(AA,1), AA AS AB FROM TEST ORDER BY AA,AB
This is invalid order by error.

Now remove the order by and you get the expected "Operation Invalid" error because you are using a memo in a distinct clause.
CREATE CURSOR test (aa m)

SELECT DISTINCT LEFT(AA,1), AA AS AB FROM TEST ORDER BY 1
One more.
Can't use the memo in an order by
CREATE CURSOR test (aa m)

SELECT AA FROM TEST ORDER BY 1
Previous
Reply
Map
View

Click here to load this message in the networking platform