1

我用 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”上创建索引,因为它包含排名或聚合窗口函数。从视图定义中删除该函数,或者不索引视图。

任何想法如何更改查询?谢谢

4

1 回答 1

0

阅读以下索引视图中允许的内容 http://technet.microsoft.com/en-us/library/ms191432(v=sql.100).aspx 你是我认为使用 Rowset 函数。

于 2013-09-11T16:33:19.567 回答