我已经定义了返回包含 2 列的表的函数。我可以重命名这些列,以便生成的表如下所示:
Press name | Sum of pages
?
CREATE FUNCTION F_3
(@press nvarchar(255))
RETURNS @table TABLE ( Press nvarchar(255),
PagesSum int )
AS
BEGIN
INSERT @table SELECT @press, SUM(Books.Pages)
FROM Books, Press
WHERE Press.Name = @press AND
Books.Id_Press = Press.Id
GROUP BY Press.Name
RETURN
END
GO
SELECT * FROM F_3('BHV')
GO
我试过这样做
Press AS 'Press name' nvarchar(255)
但这行不通。