【发布时间】:2011-06-19 18:46:15
【问题描述】:
我需要为我的联合查询实现分页,但我收到错误消息“Msg 102, Level 15, State 1, Line 14 ')' 附近的语法不正确。”。我按照从 link 中找到的示例进行操作。
select *
from (select Id,
row_number() OVER (order by Id asc) as RowNumber
from (select Id
from (select Id
from Table1) as table1
union all
select Id
from (select Id
from Table2) as table2)) as t Derived
WHERE RowNumber > 5
and RowNumber <= 10
【问题讨论】:
-
发生了什么?你有错误吗?
-
更新了答案以包含错误消息。
-
我从不喜欢 SQL Server 的错误位置,但我在你的代码中数了 12 行。有什么没贴的吗?
-
我刚刚删除了真实的列名,所以它可能比真实的查询短。
标签: sql sql-server tsql sql-server-2008 pagination