Re: [SQL] group by and order by

From: Steve <stephen_wilcock_at_hotmail.com>
Date: 20 Jan 2003 08:13:18 -0800
Message-ID: <9397750b.0301200813.697d449f_at_posting.google.com>


erwanpianezza_at_my-deja.com (Erwan) wrote in message news:<ef3d78e5.0301200320.4d50428e_at_posting.google.com>...
> Hi, how is it possible to order a group by query on a field that is
> aggregated ?
>
> I get the famous ORA-00979 error when i run this one :
>
> select ext_profil_id, ext_code, count(ext_log_date) as nb_connect
> from ext_log, extranet_pro where ext_log.ext_profil_id=
> extranet_pro.id and ext_action_id=1 group by ext_profil_id, ext_code
> order by ext_log_date
>
> thanks,
>
> erwan in kemper.

You are ordering by ext_log_date yet you have used "count(ext_log_date) as nb_connect" in the select clause. Try "order by nb_connect" and maybe table name aliases rather than only prefixing columns in the where clause.

Steve Received on Mon Jan 20 2003 - 17:13:18 CET

Original text of this message