Re: [SQL] Ordering a date_part() query ... - Mailing list pgsql-sql

From Bruce Momjian
Subject Re: [SQL] Ordering a date_part() query ...
Date
Msg-id 200001181828.NAA05364@candle.pha.pa.us
Whole thread Raw
In response to Re: [SQL] Ordering a date_part() query ...  (Mark Volpe <volpe.mark@epamail.epa.gov>)
List pgsql-sql
> The Hermit Hacker wrote:
> > 
> > I have a query that looks like:
> > 
> > SELECT ( date_part('month', stat_period) || '/' ||
> >          date_part('day', stat_period)   || '/' ||
> >          date_part('year', stat_period)  || ' ' ||
> >          date_part('hour', stat_period)  || ':00:00' ) as "Summary - by
> > Day/Hour",
> >        sum(impressions) as impressions, sum(click_thru) as click_thru
> >   FROM banner_count
> > GROUP BY "Summary - by Day/Hour";
> > 
> 
> Try appending ORDER BY "Summary - by Day/Hour"::date
> to your query.

Oh, much better than my CASE idea.  I thought he was sorting date/time
strings, not datetime values.

--  Bruce Momjian                        |  http://www.op.net/~candle pgman@candle.pha.pa.us               |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-sql by date:

Previous
From: Mark Volpe
Date:
Subject: Re: [SQL] Ordering a date_part() query ...
Next
From: Bruce Momjian
Date:
Subject: Re: [SQL] Ordering a date_part() query ...