查找某字段第N大值--level connect by prior 的使用

rem -----------------------------------------------------------------------rem Filename: maxvalue.sqlrem Purpose: Select the Nth highest value from a tablerem Date: 18-Apr-2001rem Author: Deepak Rai, SSE, Satyam Computer Services Ltd. Indiarem -----------------------------------------------------------------------select level, max('col_name') from my_tablewhere level = '&n'connect by prior ('col_name') > 'col_name')group by level;-- Example :---- Given a table called emp with the following columns:-- id number-- name varchar2(20)-- sal number---- For the second highest salary:---- select level, max(sal) from emp-- where level=2-- connect by prior sal > sal-- group by level--

你可能感兴趣的:(查找,使用,字段)