Re: [GENERAL] Grouping Question

2009-07-31 Thread Ketema Harris
OK that worked, but now how do I get the integer returned by extract into a human friendly string like 7/1 - 7/8 or something similar ? On Jul 31, 2009, at 12:37 PM, Rob Wickert wrote: You would use some of postgresql built in date functions to extract the week from the date and group by tha

Re: [GENERAL] Grouping Question

2009-07-31 Thread Rob Wickert
You would use some of postgresql built in date functions to extract the week from the date and group by that i.e. select carrier, extract(week from start_time) as week, sum(call_length) as totallength, sum(cost) as total_cost from mytable group by carrier, extract(week from start_time) order

Re: [GENERAL] Grouping Question

2009-07-31 Thread Gerhard Heift
On Fri, Jul 31, 2009 at 12:09:51PM -0400, Ketema Harris wrote: > I have a table defined as > > CREATE TABLE mytable > ( > carrier varchar, > start_time timestamp with time zone, > call_date date, > cost numeric, > call_length numeric > ) > > I want to create a query that will generate a

Re: [GENERAL] Grouping Question

2009-07-31 Thread Sam Mason
On Fri, Jul 31, 2009 at 12:09:51PM -0400, Ketema Harris wrote: > I want to create a query that will generate a the following columns: > > carrier, week, sum(call_length) as totallength, sum(cost) as total_cost > from mytable > group by carrier, (WHAT HERE?) > order by week, carrier > > week is de