Em Friday 22 February 2008 13:10:20 Justin escreveu: > I'm not after small code i'm after maintainable code where the date > range for this report would be always changing. So if i can get it to > one select statement i would on have to pass in some variables and it > would create the moving average. Plus what if the sales people decide > they want to change moving average from 10 weeks to 5 weeks or change it > to 15 weeks. People drive me nuts with i want it to do this or that , > Of course they have no idea how complicated it sometimes to get what > they want. Then just add more parameters to your function. Instead of just start date also include an optional period, in weeks, days, hours, whatever you think is the better granularity for this. So, in your interface, add the period and make "10" the default value. -- Jorge Godoy <jgodoy@xxxxxxxxx> ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend