On 2008-02-21 13:37, Justin wrote:
... 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???
Break down your problem using VIEWs. Create a VIEW that gets just ONE
of the averages, based on a starting date. Then create a SELECT that
gets data from the VIEW as though it was an actual table.
Once you get it working, you can replace the reference to the VIEWs in
the SELECT statement, with the definition of the VIEWs, but I would not
do that unless the result is relatively simple and easy to understand.
Maintainability should be your goal.
-- Dean
--
Mail to my list address MUST be sent via the mailing list.
All other mail to my list address will bounce.
---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match