At 19:41 +0200 5/5/04, Julien Martin wrote:
Hello,
Thanks a lot for the replies. I have changed the query as follows:
**
SELECT
DB_ESTABLISHMENT_NAME,
AVG(DB_GRADE)
FROM
ESTABLISHMENTS ES LEFT OUTER JOIN GRADES GR ON
ES.DB_ESTABLISHMENT_ID=GR.DB_EST
Pretty simple, declare an alias in your query and use it in the ORDER BY, i.e.:
SELECT DB_ESTABLISHMENT_NAME, AVG(DB_GRADE) AS AVGGRADEFROM ESTABLISHMENTS ES LEFT OUTER JOIN GRADES GR ONES.DB_ESTABLISHMENT_ID=GR.DB_ESTABLISHMENT_IDGROUP BY ES.DB_ESTABLISHMENT_IDHAVING AVG(DB_GRADE) > 2ORDER B
In Oracle you can reference the second field AVG() by the field #.
ORDER BY 2
> Thanks a lot for the replies. I have changed the query as follows:
>
> **
> SELECT
> DB_ESTABLISHMENT_NAME,
> AVG(DB_GRADE)
>
> FROM
> ESTABLISHMENTS ES LEFT OUTER JOIN GRADES
On Wed, 5 May 2004 19:41:32 +0200
Julien Martin <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Thanks a lot for the replies. I have changed the query as follows:
>
> **
> SELECT
> DB_ESTABLISHMENT_NAME,
> AVG(DB_GRADE)
>
> FROM
> ESTABLISHMENTS ES L
What kind of problem are you having? You can use the ordinal postion.
ORDER BY 2 [ASC|DESC]. 2 represents the second column.
-Original Message-
From: Julien Martin
To: '[EMAIL PROTECTED]'
Sent: 5/5/04 12:41 PM
Subject: AVG function in order by clause
Hello,
Thanks a lot for the replies.