Search Postgresql Archives

need some help on figuring out how to write a query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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???

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

              http://archives.postgresql.org/

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux