我用 Schemabinding 创建了这个视图:
CREATE VIEW RANKING_OPTIMIZATION_VIEW
WITH SCHEMABINDING
AS
SELECT USERS.[USER_ID],
USERS.GAMERTAG,
CLASSIFICATION.WIDGET_ID,
CLASSIFICATION.CLASSIFICATIONTYPE_ID,
ROW_NUMBER() OVER(PARTITION BY CLASSIFICATION.WIDGET_ID,
CLASSIFICATION.CLASSIFICATIONTYPE_ID
ORDER BY CLASSIFICATION.[SCORE] DESC ) AS RANKING,
CLASSIFICATION.WIN,
CLASSIFICATION.LOSE,
CLASSIFICATION.SCORE
FROM [dbo].[GMW_CLASSIFICATION] AS CLASSIFICATION
INNER JOIN [dbo].[GMW_USERS] AS USERS
ON USERS.[USER_ID] = CLASSIFICATION.[USER_ID]
INNER JOIN [dbo].[GMW_WIDGET_GAMETYPES] AS GAMETYPE
ON GAMETYPE.[WIDGET_ID] = CLASSIFICATION.[WIDGET_ID]
AND GAMETYPE.[GAMETYPE_ID] = CLASSIFICATION.[CLASSIFICATIONTYPE_ID]
我收到此错误:无法在视图“GameRoomDev.dbo.RANKING_OPTIMIZATION_VIEW”上创建索引,因为它包含排名或聚合窗口函数。从视图定义中删除该函数,或者不索引视图。
任何想法如何更改查询?谢谢