What is the simplest way to get the nth highest value from a result set using plain SQL?
The result set would be huge, thus need to consider performance too.>
Start by producing an ordered, numbered dataset and then select from that. The precise syntax depends on the RDBMS but, for example, in Oracle you can do
SELECT ROWNUM, SOMEVAL FROM (SELECT SOMEVAL FROM SOMETABLE ORDER BY SOMEVAL DESC)
Given the above set you can
SELECT SOMEVAL WHERE ROWNUM = :N