Expr1002

A

aak

I have a query something like this. I want to order it by total. Everything else works OK
only ordering doesn't work. It displays me window - 'Enter Parameter Value'. If I enter
something, it displays it again, and so four times. And it DOESN'T order by total anyway.
I have tried without 'as total' clause and tried to 'order by Expr1002' but nothing works.
What's the point?

Please advice.

select title, element, SUM(proce) as total FROM
(SELECT blaah, blaah
Union
SELECT blaah, blaah
Union
SELECT blaah, blaah
Union
SELECT blaah, blaah )
GROUP BY element, title order by total
 
M

Marshall Barton

aak said:
I have a query something like this. I want to order it by total. Everything else works OK
only ordering doesn't work. It displays me window - 'Enter Parameter Value'. If I enter
something, it displays it again, and so four times. And it DOESN'T order by total anyway.
I have tried without 'as total' clause and tried to 'order by Expr1002' but nothing works.
What's the point?

Please advice.

select title, element, SUM(proce) as total FROM
(SELECT blaah, blaah
Union
SELECT blaah, blaah
Union
SELECT blaah, blaah
Union
SELECT blaah, blaah )
GROUP BY element, title order by total


Don't ask me why, but you can not use an alias name in the
Order By clause. The straightforward way is to repeat the
expression:

ORDER BY SUM(proce)

That can get to be messy with longer expressions so you may
want to use an alternat syntax where you can specify the
number of the field. E.g:

ORDER BY 3
 
Top