Надеюсь, это поможет.
CREATE FUNCTION fn_ReturnTaxedPrice
(
@ProductID int,
@GST float
)
RETURNS money --this is the correct data type for money
AS
BEGIN
DECLARE @Price money
SET @Price = (SELECT Price FROM Products WHERE ProductID = @ProductID)
RETURN @Price * @GST
END
Это должно работать сейчас.
CREATE VIEW vw_SalesDetails
AS
SELECT Sales.SaleNo,
Sales.SaleDate,
Customer.FirstName,
Customer.LastName,
Category.Category,
Products.ProductDescription,
Type.Type,
Products.Year,
Products.Price,
dbo.fn_ReturnTaxedPrice(Products.ProductID, 0.1) AS GST,
dbo.fn_ReturnTaxedPrice(Products.ProductID, 0.1) + Products.Price AS TotalPrice
FROM Category
JOIN Customer ON Category.CategoryID = Customer.CategoryID
JOIN Sales ON Customer.CustomerID = Sales.CustomerID
JOIN SalesProducts ON Sales.SaleNo = SalesProducts.SaleNo
JOIN Products ON Products.ProductID = SalesProducts.ProductID
JOIN ProductType ON Products.ProductID = ProductType.ProductID
JOIN Type ON Type.TypeID = ProductType.TypeID