Subject Sorting problem
Author Riho-Rene Ellermaa
I can't get the query to sort correctly for field 'accountno'

My Query is:
SELECT (select account from v_account a where a.id=c.accid and c.docdate
between a.sdate and a.edate) as accountno
,for_pay.id,BANK , ACCID , STATUS
, IBANK
, c.CURRENCY
FROM for_pay c
join account on account.id=accid and uid=:UID and install=:INST

Ordering is:
Account=1;1 DESC
ID=for_pay.ID;for_pay.ID DESC


If I run this query from IBAdmin
....
join account on account.id=accid and uid=:UID and install=:INST
order by 1
then the sorting works OK. If I run it in IBO 4.2Ib, then the sorting is
done by field 'for_pay.id'.
If I try to change the 1 with 2, like
Account=2;2 DESC
then I get error :"Invalid ORDER BY clause"


Looks like IBO reorders something or does something behind the scenes.
Any comments, solutions?

Riho Ellermaa