UNION with grouping? - Mailing list pgsql-sql

From Bill Carlson
Subject UNION with grouping?
Date
Msg-id Pine.LNX.4.04.9904220903320.7704-100000@wally.kinze.com
Whole thread Raw
List pgsql-sql
Hello,

Is this a legal query? When I execute it postgres dumps core. I know the
types match in each select.


select route,
sum(date_part('epoch',age(termdate,startdate))) as inuse,
date_part('year',startdate) as year,
date_part('month',startdate) as month,
date_part('day',startdate) as day,
date_part('hour',startdate) as hour,
date_part('minute',startdate) as minute,
date_part('second',startdate) as second
from incomingcalls
where startdate between '4/16/99' and '4/16/99/ 23:59:59'
group by route,year,month,day,hour,minute,second

UNION ALL
select route,
sum(date_part('epoch',age(termdate,startdate))) as inuse,
date_part('year',startdate) as year,
date_part('month',startdate) as month,
date_part('day',startdate) as day,
date_part('hour',startdate) as hour,
date_part('minute',startdate) as minute,
date_part('second',startdate) as second
from outgoingcalls
where startdate between '4/16/99' and '4/16/99/ 23:59:59'
group by route,year,month,day,hour,minute,second

Any help appreciated.

Bill Carlson            |    Opinions expressed are my own
KINZE Manufacturing, Inc.    |    not my employer's.




pgsql-sql by date:

Previous
From: José Soares
Date:
Subject: Re: [SQL] convert text to number or number to text
Next
From: Julian Scarfe
Date:
Subject: Finding the "most recent" rows