Если вы знаете, что у вас есть все перестановки в таблице, запрос будет относительно простым
SQL> with x as (
2 select 1 a, 2 b, 3 c from dual
3 union all
4 select 1, 3, 2 from dual
5 union all
6 select 2, 1, 3 from dual
7 union all
8 select 2, 3, 1 from dual
9 union all
10 select 3, 1, 2 from dual
11 union all
12 select 3, 2, 1 from dual
13 union all
14 select 4, 6, 5 from dual
15 union all
16 select 4, 5, 6 from dual
17 union all
18 select 5, 4, 6 from dual
19 union all
20 select 5, 6, 4 from dual
21 )
22 select a, b, c
23 from x
24 where a < b
25 and b < c;
A B C
---------- ---------- ----------
1 2 3
4 5 6
Если вы не знаете, что у вас будут все перестановки в таблице, жизнь будет намного сложнее. Но что-то вроде этого должно работать.
SQL> ed
Wrote file afiedt.buf
1 with x as (
2 select 1 a, 2 b, 3 c from dual
3 union all
4 select 1, 3, 2 from dual
5 union all
6 select 2, 1, 3 from dual
7 union all
8 select 2, 3, 1 from dual
9 union all
10 select 3, 1, 2 from dual
11 union all
12 select 3, 2, 1 from dual
13 union all
14 select 4, 6, 5 from dual
15 union all
16 select 4, 5, 6 from dual
17 union all
18 select 5, 4, 6 from dual
19 union all
20 select 5, 6, 4 from dual
21 )
22 select a,
23 b,
24 c
25 from (
26 select a,
27 b,
28 c,
29 min_abc,
30 middle_abc,
31 max_abc,
32 row_number() over( partition by min_abc,
33 middle_abc,
34 max_abc
35 order by a,
36 b,
37 c ) rn
38 from (
39 select (case when a not in (min_abc, max_abc)
40 then a
41 when b not in (min_abc, max_abc)
42 then b
43 else c
44 end) middle_abc,
45 min_abc,
46 max_abc,
47 a,
48 b,
49 c
50 from (
51 select least(a, b, c) min_abc,
52 greatest(a,b,c) max_abc,
53 a,
54 b,
55 c
56 from x ) get_min_max
57 ) get_middle
58 ) get_rn
59* where rn = 1
SQL> /
A B C
---------- ---------- ----------
1 2 3
4 5 6