sql读出第10条到第18条的信息

来源:百度知道 编辑:UC知道 时间:2024/06/29 02:27:19
select top 18 ClassID,ClassName,Depth,NextID,LinkUrl,Child,Readme,rootid From MenuClass where rootid not in(select top 9 * From MenuClass where Depth=0 and ShowOnTop=True order by RootID) and Depth=0 and ShowOnTop=True order by RootID order by rootid
这样写好像不对呢
请高手指教

WITH MenuClass2 AS
(SELECT ClassID,ClassName,Depth,NextID,LinkUrl,Child,Readme,rootid,
ROW_NUMBER() OVER (order by RootID desc)as RowNumber
From MenuClass )
SELECT *
FROM MenuClass2
WHERE RowNumber between 10 and 18;

SQLSERVER2005测试通过

select top 18 ClassID,ClassName,Depth,NextID,LinkUrl,Child,Readme,rootid From MenuClass
where Depth=0 and ShowOnTop=True and rootid not in(select top 9 * From MenuClass order by RootID) order by RootID

这样行不?

youke

帮你修改下,不知道对不对,试试就行了.。
查询的是只要不是0-9的数据,。10以后的数据都能查询出来.。

select top 18 ClassID,ClassName,Depth,NextID,LinkUrl,Child,Readme,rootid From MenuClass where rootid not in(select top 9 * From MenuClass where Depth=0 and Depth=9 order by RootID) order by RootID order by rootid