set rowcount 5
select * from 表 where id=1 order by orders desc
set rowcount 0

解决方案 »

  1.   

    这样可以么?
    select * from tb 
    where Orders exists
    (select max(Orders) from tb where id=1 group by Opr) t1
      

  2.   

    楼上这样好像是差不多,不过这条语句不能运行
    select * from tb 
    where Orders exists
    (select max(Orders) from tb where id=1 group by Opr) t1在关键字 'exists' 附近有语法错误。
      

  3.   

    select * from tb a where not exists (select 1 from tb where id=1 and opr=a.opr and orders>a.orders)
      

  4.   

    把 exists 先换成 Orders in试试。开始想这么写的觉得用in不太好就用了exists.
      

  5.   

    select * from tb 
    where Orders in (select max(Orders) from tb where id=1 group by Opr) t1