Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D50F847667E for ; Tue, 3 Dec 2002 18:31:28 -0500 (EST) Received: from beamish.nsd.ca (unknown [205.150.156.194]) by postgresql.org (Postfix) with ESMTP id ACBDC4759AF for ; Tue, 3 Dec 2002 18:29:41 -0500 (EST) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id SAA15103; Tue, 3 Dec 2002 18:29:41 -0500 X-Authentication-Warning: beamish.nsd.ca: smap set sender to using -f Received: from reddog.nsd.ca(192.168.101.30) by beamish.nsd.ca via smap (V2.1/2.1+anti-relay+anti-spam) id xma015101; Tue, 3 Dec 02 18:29:19 -0500 Received: from nsd.ca (jllachan-linux.nsd.ca [192.168.101.148]) by reddog.nsd.ca (8.8.7/8.8.7) with ESMTP id SAA26412; Tue, 3 Dec 2002 18:28:00 -0500 Message-ID: <3DED3E60.E632DA8@nsd.ca> Date: Tue, 03 Dec 2002 18:29:36 -0500 From: Jean-Luc Lachance X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.9-31 i686) X-Accept-Language: en MIME-Version: 1.0 To: Hunter Hillegas Cc: PostgreSQL Subject: Re: [OFFTOPIC] Query Help References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/197 X-Sequence-Number: 34112 Try: select username, avg(date_difference) from sample_request_average_days group by salesperson, to_char( date_shipped, 'YYYYMM'); Hunter Hillegas wrote: > > Someone asked me to create a query for them that would compute some averages > for them over time. > > Basically I have a view that looks like this: > > sample_request_line_item_number | integer | > sample_origin | character varying | > date_of_request | timestamp with time zone | > username | character varying | > date_shipped | date | > date_difference | double precision | > > I have a query that does what I need: > > > date_shipped between '2002-11-01' and '2002-11-30' group by username; > > Basically it is getting the average number of days it took to ship something > by salesperson, by month. > > The problem is that I want it to print the results for each month for which > there are entries (without hard-coding dates). > > Is there any easy way to do this that I'm missing? > > Any help appreciated. Please reply off-list to minimize noise. > > Thanks, > Hunter > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org