1
我有3個數據庫(下面分別列出了實際查詢),我已將工會查詢在一起。我試圖在3個基礎上獲得最低的成本。 一個常見的是MFG零件號,所以我想這樣做以及所有3個供應商的最低價格。 我創建了一個聯合查詢,看起來像這樣:僅使用零件號和成本顯示各種數據庫上物品的最低成本
SELECT INGRAM.[MFG NAME], INGRAM.[MFG PART NO], INGRAM.[DESCRIPT 1] AS DESCRIPTION, INGRAM.Cost, INGRAM.MLP AS [LIST PRICE], INGRAM.[INGRAM PARTNO] AS [VENDOR SKU], INGRAM.LGTH AS COO
FROM INGRAM
UNION ALL
SELECT [SYNNEX CURRENT].[MFG NAME], [SYNNEX CURRENT].[MFG PART NO], [SYNNEX CURRENT].[Part Description] AS DESCRIPTION, [SYNNEX CURRENT].Cost, [SYNNEX CURRENT].MSRP AS [LIST PRICE], [SYNNEX CURRENT].[SYNNEX SKU] AS [VENDOR SKU], [SYNNEX CURRENT].[Country of Origin] AS COO
FROM [SYNNEX CURRENT]
UNION ALL
SELECT [Digitek Product Catalog].Manufacturer AS [MFG NAME], [Digitek Product Catalog].[Part No] AS [MFG PART NO], [Digitek Product Catalog].Description AS DESCRIPTION, [Digitek Product Catalog].[Unit Price] AS Cost, [Digitek Product Catalog].[List Price], [Digitek Product Catalog].[Part No] AS [VENDOR SKU], [Digitek Product Catalog].[Country Of Origin] AS COO
FROM [Digitek Product Catalog]
ORDER BY [MFG PART NO];
這結合了所有的目錄爲一體。
然後我運行另一個查詢來嘗試獲取成本列中的最小值,但是由於MFG NAME列包含同一製造商的不同名稱(取決於供應商)以及供應商SKU也不同。
我想要一個顯示我所有信息的結果,但只返回同一個MFG PART NO中的最佳成本。