I am trying to run a query based on two other queries i have created to calculate tolat yield for product. Here is the SQL for the query:
SELECT qry_search_premiumtot.Trailer_ID, qry_search_premiumtot.Employee_ID, qry_search_premiumtot.Production_Date, qry_search_premiumtot.Stage_ID, [qry_search_premiumtot]!Sum/[qry_search_rm]!Sum AS Yield
FROM qry_search_premiumtot INNER JOIN qry_search_rm ON qry_search_premiumtot.Production_Date = qry_search_rm.Production_Date
GROUP BY qry_search_premiumtot.Trailer_ID, qry_search_premiumtot.Employee_ID, qry_search_premiumtot.Production_Date, qry_search_premiumtot.Stage_ID
HAVING (((qry_search_premiumtot.Stage_ID)=[Stage ID]));
The following two are the SQL for the querries I want to calculate:
SELECT tbl_Stageing.Trailer_ID, tbl_Stageing.Production_Date, tbl_Stageing.Employee_ID, First(tbl_Stageing.Stage_ID) AS FirstOfStage_ID, First(tbl_Stageing.Product_Category) AS FirstOfProduct_Category, tbl_Stageing.Product_Condition, Sum(tbl_Stageing.Product_Weight_lbs) AS [Sum]
FROM tbl_Stageing
WHERE (((tbl_Stageing.Product_Condition)="raw") AND ((tbl_Stageing.Product_Category)="material"))
GROUP BY tbl_Stageing.Trailer_ID, tbl_Stageing.Production_Date, tbl_Stageing.Employee_ID, tbl_Stageing.Product_Condition;
AND
SELECT tbl_Stageing.Trailer_ID, tbl_Stageing.Employee_ID, tbl_Stageing.Production_Date, tbl_Stageing.Stage_ID, Sum(tbl_Stageing.Product_Weight_lbs) AS [Sum]
FROM tbl_Stageing
WHERE (((tbl_Stageing.Product_Condition)="Premium") AND ((tbl_Stageing.Product_Category)<>"Material"))
GROUP BY tbl_Stageing.Trailer_ID, tbl_Stageing.Employee_ID, tbl_Stageing.Production_Date, tbl_Stageing.Stage_ID
HAVING (((tbl_Stageing.Stage_ID)=[Stage ID]));
In the first query i posted, [qry_search_premiumtot]!Sum/[qry_search_rm]!Sum AS Yield returns an error saying that this is not part of an aggregate function (When I change the "Total" row to "Expression") . How do i solve this problem?
Thanks!
Kumail
SELECT qry_search_premiumtot.Trailer_ID, qry_search_premiumtot.Employee_ID, qry_search_premiumtot.Production_Date, qry_search_premiumtot.Stage_ID, [qry_search_premiumtot]!Sum/[qry_search_rm]!Sum AS Yield
FROM qry_search_premiumtot INNER JOIN qry_search_rm ON qry_search_premiumtot.Production_Date = qry_search_rm.Production_Date
GROUP BY qry_search_premiumtot.Trailer_ID, qry_search_premiumtot.Employee_ID, qry_search_premiumtot.Production_Date, qry_search_premiumtot.Stage_ID
HAVING (((qry_search_premiumtot.Stage_ID)=[Stage ID]));
The following two are the SQL for the querries I want to calculate:
SELECT tbl_Stageing.Trailer_ID, tbl_Stageing.Production_Date, tbl_Stageing.Employee_ID, First(tbl_Stageing.Stage_ID) AS FirstOfStage_ID, First(tbl_Stageing.Product_Category) AS FirstOfProduct_Category, tbl_Stageing.Product_Condition, Sum(tbl_Stageing.Product_Weight_lbs) AS [Sum]
FROM tbl_Stageing
WHERE (((tbl_Stageing.Product_Condition)="raw") AND ((tbl_Stageing.Product_Category)="material"))
GROUP BY tbl_Stageing.Trailer_ID, tbl_Stageing.Production_Date, tbl_Stageing.Employee_ID, tbl_Stageing.Product_Condition;
AND
SELECT tbl_Stageing.Trailer_ID, tbl_Stageing.Employee_ID, tbl_Stageing.Production_Date, tbl_Stageing.Stage_ID, Sum(tbl_Stageing.Product_Weight_lbs) AS [Sum]
FROM tbl_Stageing
WHERE (((tbl_Stageing.Product_Condition)="Premium") AND ((tbl_Stageing.Product_Category)<>"Material"))
GROUP BY tbl_Stageing.Trailer_ID, tbl_Stageing.Employee_ID, tbl_Stageing.Production_Date, tbl_Stageing.Stage_ID
HAVING (((tbl_Stageing.Stage_ID)=[Stage ID]));
In the first query i posted, [qry_search_premiumtot]!Sum/[qry_search_rm]!Sum AS Yield returns an error saying that this is not part of an aggregate function (When I change the "Total" row to "Expression") . How do i solve this problem?
Thanks!
Kumail