UNION with grouping?

From: Bill Carlson <wcarlson(at)kinzemfg(dot)com>
To: pgsql-sql(at)hub(dot)org
Subject: UNION with grouping?
Date: 1999-04-22 14:05:59
Message-ID: Pine.LNX.4.04.9904220903320.7704-100000@wally.kinze.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Browse pgsql-sql by date

  From Date Subject
Next Message Julian Scarfe 1999-04-22 14:14:46 Finding the "most recent" rows
Previous Message José Soares 1999-04-22 12:29:56 Re: [SQL] convert text to number or number to text