我正在尝试使用聚合AVG创建索引视图,但无法使其工作。有人试过吗?我发现this文章,但无法弄清楚如何使其发挥作用。这是我的剧本:
CREATE VIEW MyView
WITH SCHEMABINDING
AS
SELECT
Id, AVG(Age) as AvgAge, COUNT_BIG(*) as CountBig
FROM
dbo.Student
GROUP BY
Id;
GO
CREATE UNIQUE CLUSTERED INDEX MyIndex ON MyView(Id);
我理解MIN
和MAX
是不可能的,但为什么不AVG
?