Verify Product Cost Rollup
All Products
select p1.product_class,p1.product_code,p1.description_1,p1.standard_cost, sum(qty_assembly*p2.standard_cost) "Calc Std Cost", (sum(qty_assembly*p2.standard_cost))-p1.standard_cost "Diff" from artprod p1 inner join artprstr x on p1.product_code=x.assy_product_code inner join artprod p2 on x.comp_product_code=p2.product_code group by p1.product_class, p1.product_code,p1.description_1,p1.standard_cost order by 1 ,2 order by 1
Products with cost mis-match
select p1.product_class,p1.product_code,p1.description_1,p1.standard_cost, sum(qty_assembly*p2.standard_cost) "Calc Std Cost", (sum(qty_assembly*p2.standard_cost))-p1.standard_cost "Diff" from artprod p1 inner join artprstr x on p1.product_code=x.assy_product_code inner join artprod p2 on x.comp_product_code=p2.product_code where abs(p1.standard_cost- (select sum(x2.qty_assembly*p3.standard_cost) from artprstr x2 inner join artprod p3 on x2.comp_product_code=p3.product_code where p1.product_code=x2.assy_product_code ))> .0001 group by p1.product_class, p1.product_code,p1.description_1,p1.standard_cost order by 1 ,2