Just wondering if anyone could help. We are using the MSSQL tool within Crystal Reports to try to create one SQL query to give us results of the SUM of each PartNo from three tables. This SQL query works as individual summations, but we want to sum the parts again at the end.
(The report basically tells how many parts were used from three areas) I know this could be done within Crystal Reports like it is, but is there a way to do it within the SQL instead?? Thanks in advance.
SELECT kitsedittable_0.PartNo, kitsedittable_0.PartDescription, SUM(kitsedittable_0.Qty*kitsforinvoice_0.KitQty) AS Qty, kitsedittable_0.PartPrice, kitsforinvoice_0.Modified FROM kitsedittable kitsedittable_0, kitsforinvoice kitsforinvoice_0 WHERE kitsedittable_0.KitID = kitsforinvoice_0.KitNo GROUP BY PartNo
UNION
SELECT nonstockedparts.PartNo, nonstockedparts.PartDescription, SUM(nonstockedparts.Qty), nonstockedparts.Price, nonstockedparts.Modified From nonstockedparts GROUP BY PartNo
UNION
SELECT partsforinvoice.PartNo, partsforinvoice.PartDescription, SUM(partsforinvoice.Qty), partsforinvoice.PartPrice, partsforinvoice.Modified FROM partsforinvoice GROUP BY PartNo
(The report basically tells how many parts were used from three areas) I know this could be done within Crystal Reports like it is, but is there a way to do it within the SQL instead?? Thanks in advance.
SELECT kitsedittable_0.PartNo, kitsedittable_0.PartDescription, SUM(kitsedittable_0.Qty*kitsforinvoice_0.KitQty) AS Qty, kitsedittable_0.PartPrice, kitsforinvoice_0.Modified FROM kitsedittable kitsedittable_0, kitsforinvoice kitsforinvoice_0 WHERE kitsedittable_0.KitID = kitsforinvoice_0.KitNo GROUP BY PartNo
UNION
SELECT nonstockedparts.PartNo, nonstockedparts.PartDescription, SUM(nonstockedparts.Qty), nonstockedparts.Price, nonstockedparts.Modified From nonstockedparts GROUP BY PartNo
UNION
SELECT partsforinvoice.PartNo, partsforinvoice.PartDescription, SUM(partsforinvoice.Qty), partsforinvoice.PartPrice, partsforinvoice.Modified FROM partsforinvoice GROUP BY PartNo