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 ROW_NUMBER() OVER (order by ID) as RowNum,* from config_ProdClsSet where SetType ='1' and UserType= '1' and [Enabled]='1' order by OrderIndex
把这个建成一个视图,再查询这个视图就OK了
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 > 0
order by OrderIndex