( select  rownum as num2, m2.id from
 ( Select * From X_ProfessionBook  
  Where X_ProfessionBook.X_Employee='102' and 1=1 )
   m2 order by m2.id asc ) and num2>=1 and num2<=2 order by m3.id 
这段有问题,应该是
( select  m2.id from
 ( Select * From X_ProfessionBook  
  Where X_ProfessionBook.X_Employee='102' and 1=1 )
   m2 where rownum>=1 and rownum<=2 order by m2.id) order by m3.id
吧?
而且感觉原来写的就有些问题,哪有select top 2 id之后然后再 order by 的啊?是不是应该移动到里面去啊?

解决方案 »

  1.   

    en
    谢谢楼上的
    可是为什么一运行都是说缺少右括号,执行不了
    各段的SQL单独测都好的很
    就是一起来的时候就说缺右括号
      

  2.   

    好了  解决了
     select * from ( select rownum as num,m. * from(
     Select * From X_ProfessionBook Where X_ProfessionBook.X_Employee='102'  and 1=1 ) m 
            order by m.id asc)
           m3  where 1=1 and num>=1 and num<=16 
          and m3.id not in 
           ( select  m2.id from
          ( Select * From X_ProfessionBook  
          Where X_ProfessionBook.X_Employee='102' and 1=1 order by X_ProfessionBook.id)
          m2 where rownum>=1 and rownum<=2 ) order by m3.id
    这个是对的
    结帖
      

  3.   

    回复    li_d_s(我是小鬼-骑白马的不一定是王子,也有可能是唐僧;有翅膀的不一定是天使,也有可能是鸟人!) 
       谢谢了   分全给你了