pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedTime interval sums
2+ messages / 2 participants
[nested] [flat]
* Time interval sums
@ 2006-10-02 20:58 A. R. Van Hook <hook@lake-lotawana.mo.us>
0 siblings, 1 reply; 2+ messages in thread
From: A. R. Van Hook @ 2006-10-02 20:58 UTC (permalink / raw)
To: pgsql-sql
How does one sum interval sums?
the following does not work:
select sum(stop-start::interval) as total from startstop
where sid = 545 and
2006 = date_part('year', day) and
9 = date_part('month', day)
however select stop-start::interval) as total from startstop
where sid = 545 and
2006 = date_part('year', day) and
9 = date_part('month', day)
works great but I need an overall sum
Table schema:
Table "public.startstop"
Column | Type | Modifiers
--------+------------------------+-----------
sid | integer | not null
start | time without time zone |
stop | time without time zone |
day | date | not null
thanks
--
Arthur R. Van Hook
Mayor
The City of Lake Lotawana
hook@lake-lotawana.mo.us
(816) 578-4704 - Home
(816) 578-4215 - City
(816) 564-0769 - Cell
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Time interval sums
@ 2006-10-02 21:29 Tom Lane <tgl@sss.pgh.pa.us>
parent: A. R. Van Hook <hook@lake-lotawana.mo.us>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2006-10-02 21:29 UTC (permalink / raw)
To: A. R. Van Hook <hook@lake-lotawana.mo.us>; +Cc: pgsql-sql
"A. R. Van Hook" <hook@lake-lotawana.mo.us> writes:
> How does one sum interval sums?
> the following does not work:
> select sum(stop-start::interval) as total from startstop
Define "does not work"? What did you get, what were you hoping for?
Personally I'd drop the unnecessary cast, but AFAICS there are
appropriate operators at least as far back as 7.3.
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2006-10-02 21:29 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-10-02 20:58 Time interval sums A. R. Van Hook <hook@lake-lotawana.mo.us>
2006-10-02 21:29 ` Tom Lane <tgl@sss.pgh.pa.us>
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