0
Iam试图在SQL查询,但我不能做一些事情。我想通过在此查询中使用row_number做分页,但我无法弄清楚我将不得不把“row_number之间”statement.Any帮助非常感谢。公用表表达式和枢轴
WITH cte_ana
AS (SELECT movie_id,
id,
tag_id
FROM dt_movieTag)
SELECT Kayit.*,
ROW_NUMBER() OVER (ORDER BY movie_id) as RowNum
FROM cte_ana PIVOT(MAX(id) FOR tag_id IN ([3], [5], [9]))AS Kayit
where Kayit.[3] is not null
and kayit.[5] is not null
and kayit.[9] is not null
order by movie_id
例如,我想这个从这个查询只选择几个数据(其中ROWNUM介于0和25)不能使用row_number
的where
子句所以需要嵌套的CTE
谢谢马丁,这可以帮助我 – slayer35 2011-03-23 18:35:35