0
這裏一個供應商提供的SQL函數是這樣一個問題:創建,用於輸入參數和返回用最低的成本
代碼並執行,以創建一個名爲PreferredVendor函數,它接受一個
產品ID參數作爲輸入的語句並返回具有最低成本
賣方在VendorProduct賣方ID
,這裏是表結構
Create table VendorProduct(
VendorProductID int identity primary key,
Cost decimal(12,4),
ProductID int identity foreign key references Product(ProductID),
VendorID int identity foreign key references Vendor(VendorID)
)
我到目前爲止創建的代碼如下:
CREATE FUNCTION dbo.PreferredVendor (@ProductID int)
RETURNS int
AS
BEGIN
DECLARE @LowestVendorPrice int
SELECT @LowestVendorPrice = VendorID FROM VendorProduct
WHERE ProductID = @ProductID
RETURN @LowestVendorPrice
END
GO
我一直無法找出如何在這裏使用MIN!
哪個[DBMS](https://en.wikipedia.org/wiki/DBMS)產品是您使用? 「SQL」只是一種查詢語言,而不是特定數據庫產品的名稱。 –