1

我可以在 SQL Server 中运行此查询:

 SELECT "HIRING PIPE REQ NUMBER", 
       ROW_NUMBER() 
         OVER ( 
           PARTITION BY "HIRING PIPE REQ NUMBER" 
           ORDER BY "HIRING PIPE REQ NUMBER") RowNumber 
FROM   DBO.TALENTDELIVERY_REQ_3FACTS 

但是,当我将下面的代码放入VIEW.

    SELECT "HIRING PIPE REQ NUMBER", 
       ROW_NUMBER() 
         OVER ( 
           PARTITION BY "HIRING PIPE REQ NUMBER" 
           ORDER BY "HIRING PIPE REQ NUMBER")AS RowNumber 
FROM   (SELECT * 
        FROM   DBO.TALENTDELIVERY_REQ_3FACTS) 

为什么这在 VIEW 中失败?
我怎样才能在 VIEW 中写下以上内容?

4

1 回答 1

1

试试这个——

CREATE VIEW dbo.vw_view1 AS     

    SELECT  [Hiring Pipe Req Number]
        ,   ROW_NUMBER() OVER (
                PARTITION BY [Hiring Pipe Req Number] 
                ORDER BY 1/0
            ) AS RowNumber
    FROM
    (
        SELECT *
        FROM dbo.TalentDelivery_Req_3Facts
    ) t
于 2013-08-20T06:29:17.480 回答