Link to home
Start Free TrialLog in
Avatar of dbatrainer
dbatrainer

asked on

ANSI Compliant keyword for TOP N clause

Need to find ANSI-92 compliant keyword for the TOP (n) keyword used in SQL Server Transact SQL?
Avatar of Jay Toops
Jay Toops
Flag of United States of America image

select foo, bar
  from yourtable X
 where ( select count(*)
           from yourtable  
          where foo > X.foo ) < 10

Jay
use LIMIT in MySQL and maybe others as well.
Which Database are you using??

Jay
Avatar of dbatrainer
dbatrainer

ASKER

comment to JLtoops from dbatrainer.

You're right a subquery would work, but it's resource intensive and I was hoping to find a universal ANSI compliant clause that works the same as TOP (n) for a hetergenous environment including SQL Server 2000, Oracle, Dbase, and others. One that might also allow (with ties).

Thanks for the reply
ASKER CERTIFIED SOLUTION
Avatar of Jay Toops
Jay Toops
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial