I created a user-defined function where you put in a code for an object and it finds the minimum of the prices. I'm having trouble on trying to define an alias 'Lowest Price'
for the output column.
Every time I use AS 'Lowest Price'
I get the error:
Incorrect syntax near the keyword 'AS'
CREATE FUNCTION findlowprice (@oc AS INT)
RETURNS INT
AS
BEGIN
DECLARE @return INT
SELECT @return = MIN(price) AS 'Lowest Price'
FROM online_warehouse
WHERE @oc = object_code
RETURN @return
END;
I tried AS 'Lowest Price'
in almost every line except for Line 4 BEGIN
and line 10 END;
and I still get the error.
Is there a way to define an alias for the output column in a user-defined function?