pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: The Hermit Hacker <scrappy@hub.org>
To: Mark Volpe <volpe.mark@epamail.epa.gov>
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Ordering a date_part() query ...
Date: Tue, 18 Jan 2000 15:16:29 -0400 (AST)
Message-ID: <Pine.BSF.4.21.0001181511250.23487-100000@thelab.hub.org> (raw)
In-Reply-To: <3884B5BA.C1155D45@epamail.epa.gov>


Had thought about that one:

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"
ORDER BY "Summary - by Day/Hour"::datetime;

results in:

ERROR:  attribute 'Summary - by Day/Hour' not found

But, that gave me an idea...

SELECT ( date_part('month', stat_period) || '/' ||
         date_part('day', stat_period)   || '/' ||
         date_part('year', stat_period)  || ' ' ||
         date_part('hour', stat_period)  || ':00:00' )::datetime as day,
       sum(impressions) as impressions, sum(click_thru) as click_thru
  FROM banner_count
GROUP BY day;


CASTing the results gives me what I want, and gives cleaner lookign
results then what I had :)


Summary - by Day/Hour       |impressions|click_thru
----------------------------+-----------+----------
Mon Jan 17 23:00:00 2000 EST|         63|         1
Tue Jan 18 00:00:00 2000 EST|        151|         0
Tue Jan 18 01:00:00 2000 EST|         89|         0
Tue Jan 18 02:00:00 2000 EST|        112|         0
Tue Jan 18 03:00:00 2000 EST|        178|         0
Tue Jan 18 04:00:00 2000 EST|        184|         0
Tue Jan 18 05:00:00 2000 EST|        133|         0
Tue Jan 18 06:00:00 2000 EST|        119|         0
Tue Jan 18 07:00:00 2000 EST|        148|         0
Tue Jan 18 08:00:00 2000 EST|        224|         0
Tue Jan 18 09:00:00 2000 EST|        272|         0
Tue Jan 18 10:00:00 2000 EST|        348|         4
Tue Jan 18 11:00:00 2000 EST|        804|         1
Tue Jan 18 12:00:00 2000 EST|        632|         1
Tue Jan 18 13:00:00 2000 EST|       1200|         0
Tue Jan 18 14:00:00 2000 EST|        110|         0


On Tue, 18 Jan 2000, Mark Volpe wrote:

> INSERT INTO my_brain VALUES ('clue') :-)
> 
> Whoops, Bruce's response reminded me,
> what I meant to say was
> ORDER BY "Summary - by Day/Hour"::datetime
> 
> Mark
> 
> 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";
> >
> 

Marc G. Fournier                   ICQ#7615664               IRC Nick: Scrappy
Systems Administrator @ hub.org 
primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org 




view thread (13+ messages)  latest in thread

Message-ID: <Pine.BSF.4.21.0001181511250.23487-100000@thelab.hub.org>
Permalink:  ../Pine.BSF.4.21.0001181511250.23487-100000@thelab.hub.org/
Also on:    postgresql.org/message-id/Pine.BSF.4.21.0001181511250.23487-100000@thelab.hub.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: scrappy@hub.org, volpe.mark@epamail.epa.gov
  Subject: Re: [SQL] Ordering a date_part() query ...
  In-Reply-To: <Pine.BSF.4.21.0001181511250.23487-100000@thelab.hub.org>
  References: <3884B5BA.C1155D45@epamail.epa.gov> <Pine.BSF.4.21.0001181511250.23487-100000@thelab.hub.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox