我正嘗試在用戶中爲SQL創建一個視圖。 (如下所示)在這裏,我想Sum dbo.WipPartBook.QtySupplied的值,當列dbo.WipPartBook.Job的值是相同的。基於同一視圖中的另一列在SQL視圖中插入總和
SELECT TOP (100) PERCENT dbo.vwSTKCF.StockCode, dbo.vwSTKCF.Cavity, dbo.vwSTKCF.Mass, dbo.vwSTKCF.Material, dbo.WipPartBook.Job,
dbo.WipPartBook.QtySupplied, dbo.WipPartBook.TrnDate
FROM dbo.WipPartBook INNER JOIN
dbo.InvMaster INNER JOIN
dbo.WipMaster ON dbo.InvMaster.StockCode = dbo.WipMaster.StockCode ON dbo.WipPartBook.Job = dbo.WipMaster.Job LEFT OUTER JOIN
dbo.vwSTKCF ON dbo.InvMaster.StockCode = dbo.vwSTKCF.StockCode
WHERE (dbo.vwSTKCF.StockCode = 'SC2020-01-00')
ORDER BY dbo.vwSTKCF.StockCode
您能給一些示例數據,使其更容易給你一個優化的查詢?謝謝 – swe