From: Jean-Luc Lachance <jllachan@nsd.ca>
To: Hunter Hillegas <lists@lastonepicked.com>
Cc: PostgreSQL <pgsql-general@postgresql.org>
Subject: Re: [OFFTOPIC] Query Help
Date: Tue, 03 Dec 2002 18:29:36 -0500
Message-ID: <3DED3E60.E632DA8@nsd.ca> (raw)
References: <BA127B61.80CC3%lists@lastonepicked.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: jllachan@nsd.ca, lists@lastonepicked.com
Subject: Re: [OFFTOPIC] Query Help
In-Reply-To: <3DED3E60.E632DA8@nsd.ca>
References: <BA127B61.80CC3%lists@lastonepicked.com> <3DED3E60.E632DA8@nsd.ca>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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