I am looking for a JDBC sql call for a top N query that will work with any DBMS type.
How does one retrieve N first (or least) rows from a record set? For example, how does one find the top five highest-paid employees in a given department? This attached code snipper would work for Oracle, but not SQL Server
I am not looking for the SQL Server and DB2 equavolent, but insight into a cronic application SQL problem. How is this query written to perform well and be DBMS independent? Is the better to approach to code something in the java resultSet layer?
FROM (SELECT ROWNUM,
FROM emp e
ORDER BY sal DESC)
WHERE ROWNUM < 6