J
Jon
I have an existing pair of Access queries which I need a bit of help
combining into one larger query (needed to run on a different app
where the only privilege present will be to run queries, no make-table
abilities or such).
Query 1 filters a table to specific criteria:
SELECT tblSupplierInfo.supplier_nme AS Name,
Sum(tblPurchaseOrders.total_cost) AS Total_Cost
FROM tblSupplierInfo RIGHT JOIN tblPurchaseOrders ON
tblSupplierInfo.supplier_id1 = tblPurchaseOrders.supplier_id
WHERE (((tblPurchaseOrders.status_id)<>3) AND
((Month([tblPurchaseOrders].[purchase_dte]))=[Forms]![frmUnionStation]!
[txtStartMonth]) AND ((Year([tblPurchaseOrders].
[purchase_dte]))=[Forms]![frmUnionStation]![txtStartYear]))
GROUP BY tblSupplierInfo.supplier_nme;
Query 2 generates a report based on Query 1 that gives the top 25
suppliers by dollar value and a 26th line which is the sum of all the
other suppliers tagged as "Other":
SELECT TOP 25 Query1.Name, Query1.Total_Cost
FROM Query1
ORDER BY Query1.Total_Cost DESC
UNION ALL SELECT "Other", sum(Query1.Total_Cost)
FROM Query1
WHERE Query1.Name NOT IN (
SELECT TOP 25 Query1.Name
FROM Query1
ORDER BY Query1.Total_Cost DESC);
The part before the UNION I can combine easily enough... What's giving
me fits is trying to make the part after that UNION work right. Can
anyone help out here?
combining into one larger query (needed to run on a different app
where the only privilege present will be to run queries, no make-table
abilities or such).
Query 1 filters a table to specific criteria:
SELECT tblSupplierInfo.supplier_nme AS Name,
Sum(tblPurchaseOrders.total_cost) AS Total_Cost
FROM tblSupplierInfo RIGHT JOIN tblPurchaseOrders ON
tblSupplierInfo.supplier_id1 = tblPurchaseOrders.supplier_id
WHERE (((tblPurchaseOrders.status_id)<>3) AND
((Month([tblPurchaseOrders].[purchase_dte]))=[Forms]![frmUnionStation]!
[txtStartMonth]) AND ((Year([tblPurchaseOrders].
[purchase_dte]))=[Forms]![frmUnionStation]![txtStartYear]))
GROUP BY tblSupplierInfo.supplier_nme;
Query 2 generates a report based on Query 1 that gives the top 25
suppliers by dollar value and a 26th line which is the sum of all the
other suppliers tagged as "Other":
SELECT TOP 25 Query1.Name, Query1.Total_Cost
FROM Query1
ORDER BY Query1.Total_Cost DESC
UNION ALL SELECT "Other", sum(Query1.Total_Cost)
FROM Query1
WHERE Query1.Name NOT IN (
SELECT TOP 25 Query1.Name
FROM Query1
ORDER BY Query1.Total_Cost DESC);
The part before the UNION I can combine easily enough... What's giving
me fits is trying to make the part after that UNION work right. Can
anyone help out here?