Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Statement
Message
From
03/06/2002 11:12:12
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00664067
Message ID:
00664073
Views:
21
Thanks!

>Foxpro doesn't allow expressions other than column number in the ORDER BY clause. Add expressions you want to sort on to the list of query columns and use there names in the ORDER BY clause.
SELECT Client.cn_primary, Client.cn_fname, Client.cn_lname, ;
>	Acctinfo.ai_cnprim, ;
>	Acctinfo.ai_acprim, Acctinfo.ai_dateent, Acctinfo.ai_dateext, ;
>	Trans.tr_amt, Trans.tr_date, Trans.tr_acfrom, Assetc.ac_desc, ;
>        YEAR(tr_date) AS SortYear, MONTH(tr_date) AS SortMonth ;
>...
>ORDER BY AcctInfo.ai_acprim, SortYear, SortMonth, cn_lname, cn_fname
>...
>>Hi:
>>
>>I have the following SQL statement that returns an error:
>>
>>column ai_acprim not found
>>
>>If I change the ORDER BY clause to read:
>>
>>
>>ORDER BY AcctInfo.ai_acprim cn_lname, cn_fname ;
>>
>>
>>then there is no error! What is wrong with my ORDER BY clause?
>>
>>Thanks,
>>
>>Yossi
>>
>>
>>
>>SELECT Client.cn_primary, Client.cn_fname, Client.cn_lname, ;
>>	Acctinfo.ai_cnprim, ;
>>	Acctinfo.ai_acprim, Acctinfo.ai_dateent, Acctinfo.ai_dateext, ;
>>	Trans.tr_amt, Trans.tr_date, Trans.tr_acfrom, Assetc.ac_desc ;
>>	FROM  pf!client ;
>>	INNER JOIN pf!acctinfo ;
>>	ON  Client.cn_primary = Acctinfo.ai_cnprim ;
>>	INNER JOIN pf!assetc ;
>>	ON  Acctinfo.ai_acprim = Assetc.ac_primary ;
>>	INNER JOIN pf!TRANS ;
>>	ON  Acctinfo.ai_cnprim = TRANS.tr_cnprim ;
>>	AND  Acctinfo.ai_acprim = TRANS.tr_acprim ;
>>	WHERE ASCAN(laAcPrim,Acctinfo.ai_acprim) > 0 ;
>>	AND (EMPTY(Acctinfo.ai_dateext) OR  Acctinfo.ai_dateext >= DATE(2001,1,1)) ;
>>	AND Trans.tr_type = 'T' ;
>>	AND Trans.tr_date >= DATE(1995,1,1) ;
>>	ORDER BY AcctInfo.ai_acprim, YEAR(tr_date), MONTH(tr_date), cn_lname, cn_fname ;
>>	INTO CURSOR curs1
>>
Previous
Reply
Map
View

Click here to load this message in the networking platform