need some help on figuring out how to write a query

From: Justin <justin(at)emproshunts(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: need some help on figuring out how to write a query
Date: 2008-02-21 21:37:47
Message-ID: 47BDEF2B.2050804@emproshunts.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

need to write a query for sales order table where we get the qty order *
price for all line items by week then average then create a moving
Average past 10 weeks of entered sales orders line items.

So what will happen is some one will enter a date range going back 6
month from the present date then query will need to get all the sales
order line items that falls in that date range by week, then average the
first 10 weeks, drop of the first week moving to the 2nd week to the
11th week to create another average, then drops 2nd week off then moves
3rd week to the 12th week in the query date range create another average
and so and so till the end of the date range. This will create moving
average for sales order entered.

Now i could write a function to do this or do it in C++ program that
creates query with all kinds of unions. I'm wondering if there is a way
to create this in a single select statement??
I can't think of a way to do it???

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Sullivan 2008-02-21 22:07:05 Re: Disable Triggers
Previous Message Geoffrey 2008-02-21 21:35:28 Re: Disable Triggers