Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL: ORDER BY clause is invalid
Message
De
02/04/2005 08:57:49
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
01/04/2005 14:46:47
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Novell 5.x
Database:
Visual FoxPro
Divers
Thread ID:
01000629
Message ID:
01000973
Vues:
24
Aleksey,
I use that in older versions (namely 5,6,7) without any problems.
"The temp.ssno is not in the SELECT list, that is why the error is expected." I don't expect any error, temp.ssno doesn't exist but it's an expression in select:

... right(ssn,4) as ssno ...

Result cursor would have that column and thus order by clause is valid IMHO.

"even though the query worked in prior versions, the result was not ordered by right(a.ssn,4)."

I think a. is a typo there. Prior versions order result by the expression. ie:
select distinct right(trim(title),4) as myOrder from employee order by myOrder
SELECT DISTINCT (unit_price / 10) as Price FROM orditems ORDER BY Price
Cetin


>Hi Doug,
>
>If there is a [ssno] field in the table, it takes precedence over an alias in SELECT list. So, the ORDER BY clause is translated as ORDER BY temp.ssno, temp.ssn. In VFP9, if DISTINCT clause is used, all ORDER BY items should present in SELECT list. The temp.ssno is not in the SELECT list, that is why the error is expected.
>
>BTW, even though the query worked in prior versions, the result was not ordered by right(a.ssn,4).
>
>Thanks,
>Aleksey.
>
>
>>This used to work fine in vfp3
>>
>>select distinct last_name, first_name, mid_name, ;
>>  address1, address2, city, state, zip_code, ;
>>  ' ' as packet_id,ssn, right(a.ssn,4) as ssno ;
>>  from temp ;
>>  into cursor address ;
>>  order by ssno, ssn
>>
>>How to fix in vfp9 besides making two statements?
>>How to find all like this in code?
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform