Re: Grouping by date range
| От | Ron Johnson |
|---|---|
| Тема | Re: Grouping by date range |
| Дата | |
| Msg-id | 1061405098.29044.6.camel@haggis обсуждение исходный текст |
| Ответ на | Re: Grouping by date range (Tom Lane <tgl@sss.pgh.pa.us>) |
| Ответы |
Re: Grouping by date range
|
| Список | pgsql-general |
On Wed, 2003-08-20 at 12:47, Tom Lane wrote:
> Ron Johnson <ron.l.johnson@cox.net> writes:
> > On Tue, 2003-08-19 at 02:56, Alexander Litvinov wrote:
> >> select date_part('year', date), count(*) from your_table group by
> >> date_part('year', date) order by date_part('year', date);
>
> > Is the ORDER BY really needed here?
>
> If you want the results ordered that way, yes.
Hmmmmm. I don't think so, if the ORDER BY clause is exactly the
same as the GROUP BY clause, which is the case here:
select date_part('year', date), count(*)
from your_table
group by date_part('year', date)
order by date_part('year', date);
The GROUP BY does implicit sorting, so an ORDER BY on the exact same
column(s) as the GROUP BY is redundant.
--
-----------------------------------------------------------------
Ron Johnson, Jr. ron.l.johnson@cox.net
Jefferson, LA USA
"Adventure is a sign of incompetence"
Stephanson, great polar explorer
В списке pgsql-general по дате отправления: