Current working Query:
Creates 4 columns : YTD_Sales , Average Sales, Type , Books Sold
To calculate the "Average Sales" I need to take the ytd_sales / "ALIAS" Books Sold
Now I know I cannot divide by an Alias ("books sold"). Therefore, I created a sub-query
But this gives me an error: "Cannot perform an aggregate function on an expression containing an aggregate or a sub-query."I know there is an easier way but I am just not seeing it.
A much, much easier way to achieve this would be to use the AVG aggregate.
So, instead of
You just needAVG(ytd_sales) AS "Average Sales",
answered Jul 11, 2010 at 12:16 PM
Matt Whitfield ♦♦