D
DawnTreader
Hello All
i have a question about group by. do i need to do this:
SELECT
qryrptSerialCBARPartList.ProductID,
qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc,
Sum(qryrptSerialCBARPartList.PartBlockQTY) AS TPartBlockQTY,
Sum(qryrptSerialCBARPartList.PartSkidQTY) AS TPartSkidQTY,
qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue,
"1000 Hr Maintenance" as Interval
FROM
qryrptSerialCBARPartList
WHERE
(((qryrptSerialCBARPartList.[1000HrMaint])=True))
GROUP BY
qryrptSerialCBARPartList.ProductID, qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc, qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue
UNION ALL
SELECT
qryrptSerialCBARPartList.ProductID,
qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc,
Sum(qryrptSerialCBARPartList.PartBlockQTY) AS TPartBlockQTY,
Sum(qryrptSerialCBARPartList.PartSkidQTY) AS TPartSkidQTY,
qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue,
"5000 Hr Rebuild" as Interval
FROM
qryrptSerialCBARPartList
WHERE
(((qryrptSerialCBARPartList.[5000HrRebuild])=True))
GROUP BY
qryrptSerialCBARPartList.ProductID, qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc, qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue
UNION ALL
SELECT
qryrptSerialCBARPartList.ProductID,
qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc,
Sum(qryrptSerialCBARPartList.PartBlockQTY) AS TPartBlockQTY,
Sum(qryrptSerialCBARPartList.PartSkidQTY) AS TPartSkidQTY,
qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue,
"10000 Hr Rebuild" as Interval
FROM
qryrptSerialCBARPartList
WHERE
(((qryrptSerialCBARPartList.[10000HrRebuild])=True))
GROUP BY
qryrptSerialCBARPartList.ProductID, qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc, qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue
UNION ALL
SELECT
qryrptSerialCBARPartList.ProductID,
qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc,
Sum(qryrptSerialCBARPartList.PartBlockQTY) AS TPartBlockQTY,
Sum(qryrptSerialCBARPartList.PartSkidQTY) AS TPartSkidQTY,
qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue,
"15000 Hr Rebuild" as Interval
FROM
qryrptSerialCBARPartList
WHERE
(((qryrptSerialCBARPartList.[15000HrRebuild])=True))
GROUP BY
qryrptSerialCBARPartList.ProductID, qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc, qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue
UNION ALL
SELECT
qryrptSerialCBARPartList.ProductID,
qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc,
Sum(qryrptSerialCBARPartList.PartBlockQTY) AS TPartBlockQTY,
Sum(qryrptSerialCBARPartList.PartSkidQTY) AS TPartSkidQTY,
qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue,
"20000 Hr Rebuild" as Interval
FROM
qryrptSerialCBARPartList
WHERE
(((qryrptSerialCBARPartList.[20000HrRebuild])=True))
GROUP BY
qryrptSerialCBARPartList.ProductID, qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc, qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue
UNION ALL SELECT
qryrptSerialCBARPartList.ProductID,
qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc,
Sum(qryrptSerialCBARPartList.PartBlockQTY) AS TPartBlockQTY,
Sum(qryrptSerialCBARPartList.PartSkidQTY) AS TPartSkidQTY,
qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue,
"25000 Hr Rebuild" as Interval
FROM
qryrptSerialCBARPartList
WHERE
(((qryrptSerialCBARPartList.[25000HrRebuild])=True))
GROUP BY
qryrptSerialCBARPartList.ProductID, qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc, qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue
ORDER BY Interval;
like this, or can i do one group by at the end on the Union?
any and all help appreciated.
i have a question about group by. do i need to do this:
SELECT
qryrptSerialCBARPartList.ProductID,
qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc,
Sum(qryrptSerialCBARPartList.PartBlockQTY) AS TPartBlockQTY,
Sum(qryrptSerialCBARPartList.PartSkidQTY) AS TPartSkidQTY,
qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue,
"1000 Hr Maintenance" as Interval
FROM
qryrptSerialCBARPartList
WHERE
(((qryrptSerialCBARPartList.[1000HrMaint])=True))
GROUP BY
qryrptSerialCBARPartList.ProductID, qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc, qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue
UNION ALL
SELECT
qryrptSerialCBARPartList.ProductID,
qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc,
Sum(qryrptSerialCBARPartList.PartBlockQTY) AS TPartBlockQTY,
Sum(qryrptSerialCBARPartList.PartSkidQTY) AS TPartSkidQTY,
qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue,
"5000 Hr Rebuild" as Interval
FROM
qryrptSerialCBARPartList
WHERE
(((qryrptSerialCBARPartList.[5000HrRebuild])=True))
GROUP BY
qryrptSerialCBARPartList.ProductID, qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc, qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue
UNION ALL
SELECT
qryrptSerialCBARPartList.ProductID,
qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc,
Sum(qryrptSerialCBARPartList.PartBlockQTY) AS TPartBlockQTY,
Sum(qryrptSerialCBARPartList.PartSkidQTY) AS TPartSkidQTY,
qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue,
"10000 Hr Rebuild" as Interval
FROM
qryrptSerialCBARPartList
WHERE
(((qryrptSerialCBARPartList.[10000HrRebuild])=True))
GROUP BY
qryrptSerialCBARPartList.ProductID, qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc, qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue
UNION ALL
SELECT
qryrptSerialCBARPartList.ProductID,
qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc,
Sum(qryrptSerialCBARPartList.PartBlockQTY) AS TPartBlockQTY,
Sum(qryrptSerialCBARPartList.PartSkidQTY) AS TPartSkidQTY,
qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue,
"15000 Hr Rebuild" as Interval
FROM
qryrptSerialCBARPartList
WHERE
(((qryrptSerialCBARPartList.[15000HrRebuild])=True))
GROUP BY
qryrptSerialCBARPartList.ProductID, qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc, qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue
UNION ALL
SELECT
qryrptSerialCBARPartList.ProductID,
qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc,
Sum(qryrptSerialCBARPartList.PartBlockQTY) AS TPartBlockQTY,
Sum(qryrptSerialCBARPartList.PartSkidQTY) AS TPartSkidQTY,
qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue,
"20000 Hr Rebuild" as Interval
FROM
qryrptSerialCBARPartList
WHERE
(((qryrptSerialCBARPartList.[20000HrRebuild])=True))
GROUP BY
qryrptSerialCBARPartList.ProductID, qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc, qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue
UNION ALL SELECT
qryrptSerialCBARPartList.ProductID,
qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc,
Sum(qryrptSerialCBARPartList.PartBlockQTY) AS TPartBlockQTY,
Sum(qryrptSerialCBARPartList.PartSkidQTY) AS TPartSkidQTY,
qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue,
"25000 Hr Rebuild" as Interval
FROM
qryrptSerialCBARPartList
WHERE
(((qryrptSerialCBARPartList.[25000HrRebuild])=True))
GROUP BY
qryrptSerialCBARPartList.ProductID, qryrptSerialCBARPartList.IMWPNID,
qryrptSerialCBARPartList.PartDesc, qryrptSerialCBARPartList.UnitPrice,
qryrptSerialCBARPartList.SkidValue
ORDER BY Interval;
like this, or can i do one group by at the end on the Union?
any and all help appreciated.