只需從其他的.mdb數據庫鏈接表,然後運行報表查詢這似乎是從銷售表每個分公司數據庫工會彙總查詢。一定要重命名鏈接表(BranchASales,BranchBSales,BranchCSales)如果他們共享同一個名字:
SELECT [Branch Name], Sum(Sales) As SumOfSales
FROM
(SELECT 'Branch A' As [Branch Name], Sales FROM [BranchASales]
UNION ALL
SELECT 'Branch B' As [Branch Name], Sales FROM [BranchBSales]
UNION ALL
SELECT 'Branch C' As [Branch Name], Sales FROM [BranchCSales])
GROUP BY [Branch Name]
或者,您可以運行查詢調用當前數據庫以外的來源沒有任何鏈接的表就像你指定路徑一樣。同樣地,可以查詢Excel工作簿,CSV/TXT在這種相同的方法文件:
SELECT [Branch Name], Sum(Sales) As SumOfSales
FROM
(SELECT 'Branch A' As [Branch Name], Sales FROM [C:\Path\To\Branch A.mdb].[Sales]
UNION ALL
SELECT 'Branch B' As [Branch Name], Sales FROM [C:\Path\To\Branch B.mdb].[Sales]
UNION ALL
SELECT 'Branch C' As [Branch Name], Sales FROM [C:\Path\To\Branch C.mdb].[Sales])
GROUP BY [Branch Name]
在上述兩個查詢,派生表被使用,但是與單獨的,存儲的查詢的FROM
子句SELECT
查詢可以容易地更換(與當前數據庫中的相同SELECT
)。