SQL语句如下:
select top 10 * from
( select ROW_NUMBER() OVER (order by ID) as RowNum,* from config_ProdClsSet where SetType ='1' and UserType= '1' and [Enabled]='1' order by OrderIndex
) as C
where RowNum > ((1 - 1) * 10)报以下错误:
除非另外还指定了 TOP 或 FOR XML,否则,ORDER BY 子句在视图、内联函数、派生表、子查询和公用表表达式中无效。请各位帮忙解决,谢谢!
select top 10 * from
( select ROW_NUMBER() OVER (order by ID) as RowNum,* from config_ProdClsSet where SetType ='1' and UserType= '1' and [Enabled]='1' order by OrderIndex
) as C
where RowNum > ((1 - 1) * 10)报以下错误:
除非另外还指定了 TOP 或 FOR XML,否则,ORDER BY 子句在视图、内联函数、派生表、子查询和公用表表达式中无效。请各位帮忙解决,谢谢!
select top 10 * from
( select ROW_NUMBER() OVER (order by ID) as RowNum,* from config_ProdClsSet where SetType ='1' and UserType= '1' and [Enabled]='1'
) as C
where RowNum > ((1 - 1) * 10)
select top 10 * from
( select ROW_NUMBER() OVER (order by ID) as RowNum,* from config_ProdClsSet where SetType ='1' and UserType= '1' and [Enabled]='1' order by OrderIndex
) as C
where RowNum > ((1 - 1) * 10)去掉order by OrderIndex
( select ROW_NUMBER() OVER (order by ID) as RowNum,* from config_ProdClsSet where SetType ='1' and UserType= '1' and [Enabled]='1'
) as C
where RowNum > ((1 - 1) * 10)
order by OrderIndex
把order by 放在外面
不可以去掉order by OrderIndex,必须排序才能完成需求的
order by 放在外面就不能完成需求了
select top 10 * from
( select ROW_NUMBER() OVER (order by ID) as RowNum,* from config_ProdClsSet where SetType ='1' and UserType= '1' and [Enabled]='1'
) as C
where RowNum > ((1 - 1) * 10) order by OrderIndex
( select ROW_NUMBER() OVER (order by OrderIndex,ID,) as RowNum,* from config_ProdClsSet where SetType ='1' and UserType= '1' and [Enabled]='1'
) as C
where RowNum > ((1 - 1) * 10)
是想要这样的吗?
select ROW_NUMBER() OVER (order by ID) as RowNum,* into #temp from config_ProdClsSet where SetType ='1' and UserType= '1' and [Enabled]='1' order by OrderIndexselect top 10 * from #temp where where RowNum > ((1 - 1) * 10)drop table #temp