crystalreporting
Instructor
I have two sales order tables; a header table that contains customer information for each order (one per order) and a line table that contains item information (one or more per order).
I'm trying to update a field in the header table that contains the total value of any active orders from the order line table (active lines). My query is;
UPDATE oeheader SET oeheader.total_sales =
(SELECT SUM(Round(oelines.qty * oelines.price)))FROM oelines inner JOIN oeheader on oeheader.type = oelines.type AND oeheader.order = oelines.order
and oelines.active = 'Y') where oeheader.active = 'Y'
This works fine for one order - however if two or more orders are active, then the total_sales amount in each order becomes the total for ALL active lines. In other words my SUM line is adding up all active order lines, not just those for each specific active order header.
Peter Shirley
Macola Consultant, PA and surrounding states.
I'm trying to update a field in the header table that contains the total value of any active orders from the order line table (active lines). My query is;
UPDATE oeheader SET oeheader.total_sales =
(SELECT SUM(Round(oelines.qty * oelines.price)))FROM oelines inner JOIN oeheader on oeheader.type = oelines.type AND oeheader.order = oelines.order
and oelines.active = 'Y') where oeheader.active = 'Y'
This works fine for one order - however if two or more orders are active, then the total_sales amount in each order becomes the total for ALL active lines. In other words my SUM line is adding up all active order lines, not just those for each specific active order header.
Peter Shirley
Macola Consultant, PA and surrounding states.