Initial Revision
[ohcount] / test / src_dir / sql1.sql
1 // -----------------------------------------------------------------------
2 // Filename:   minvalue.sql
3 // Purpose:    Select the Nth lowest value from a table
4 // Date:       18-Apr-2001
5 // Author:     Deepak Rai, SSE, Satyam Computer Services Ltd. India
6 // -----------------------------------------------------------------------
7
8 select level, min('col_name') from my_table
9 where level = '&n'
10 connect by prior ('col_name') < 'col_name')
11 group by level;
12
13 /* a block comment
14    -- finished here */
15
16 -- Example:
17 --
18 -- Given a table called emp with the following columns:
19 --   id   number
20 --   name varchar2(20)
21 --   sal  number
22 --
23 -- For the second lowest salary:
24 --
25 -- select level, min(sal) from emp
26 -- where level=2
27 -- connect by prior sal < sal
28 -- group by level
29 --
30