Re: [SQL] group by and order by

From: Jusung Yang <JusungYang_at_yahoo.com>
Date: 20 Jan 2003 11:14:16 -0800
Message-ID: <130ba93a.0301201114.78a8d043_at_posting.google.com>


You aggregate and then you sort the results. I don't think it makes sense to order on a field that is beging aggregated.
Order on the "results" of that aggregation would make sense. So "order by nb_connect" would work in your case, and it makes sense.

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.
Received on Mon Jan 20 2003 - 20:14:16 CET

Original text of this message