外部查询导致与子查询不同的结果集比较

时间:2014-10-07 11:03:09

标签: sql-server-2008

对于所有行,

在CTE结果row_num内查询为1。同样我选择从CTE结果row_num选择1和2是错误的。请让我知道这个缺陷或解决方案。

WITH CTE AS(
  SELECT Project_Id,
         ROW_NUMBER() over (partition by Test_Defect_Id order by Last_Modified_Date desc) as row_num 
    FROM dbo.Staging_RADAR_TestDefects
 --where Project_Id = 'PRJ-007171'
) 
SELECT * 
  FROM CTE
 WHERE Project_Id = 'PRJ-007171'

0 个答案:

没有答案