Subject Re: [ib-support] [OT ?] sql question
Author Nick Upson
Use "order by 2" instead

In article <arjinp+jgvq@...>, Duilio_fos wrote:
> >>
> select custID, sum(price*qty) from mv_li where op='PURCHASE' group by
> custID
> >>
>
> The instruction above gives me the list of all customers, together
> with the total value of the goods they purchased.
>
> This almost what I need.
>
> The final touch would be to get the list ordered by the purchase
> total, so that customers are ordered by their "weight".
>
> How do I do that ?
>
> I cannot add
>
> ...order by sum(price*qty)
>
> (The SQL parser complains as soon as the term "sum" is reached).
>
> TIA