Alias Question MySql
I have the following query that works...
SELECT tOrdersDetail.ProductId , SUM(tOrdersDetail.quantity) as Quantity1,SUM( tOrdersDetail.Price * Quantity) as Price1,tProduct.UnitPrice as uCost,SUM(Quantity * tProduct.UnitPrice) as Total_Cost .... -> wont work if i add this on ,( Quantity1/Price1) as Average_Cost
INNER JOIN tOrdersDetail
GROUP BY ProductId
LIMIT 0 , 30
I need to preform 2 more calculations in the result set...
My thought was to just add this and i can mamke calucation based on alias name....but no luck
( Quantity1/Price1) as Average_Cost
( Total_Cost/Price1) as Average_Cost
I get an error invalied field name...thanks
Last edited by psdeveloper; 11-01-2008 at 07:25 AM.
its more because quantity1 is an alias for aggregate reults. youre trying to sum a sum which doesnt work
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)