CREATE FUNCTION dbo.Portal_fnGetRestaurantRating
(@CustomerId bigint)
RETURNS int
AS
BEGIN
DECLARE
@value int
SELECT @value =
IsNull(SUM(Rating) / Count(Rating), 1) FROM Portal_CustomerReview
WHERE CustomerId = @CustomerId
RETURN @value
END
--Call the
function
SELECT dbo.Portal_fnGetRestaurantRating(8)
No comments:
Post a Comment