|
|
回复 #13 sunfly1983 的帖子
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
SQL> with tmp as
2 (select rownum rn, sum(cnt) over(order by rownum) path_cnt, path, cnt
3 from (select sys_connect_by_path(filmname, ',') path, level cnt
4 from t_film
5 where connect_by_isleaf = 1
6 start with substr(filmname, -1) = 'a'
7 or instr('abc', substr(filmname, -1)) = 0
8 connect by length(filmname) = length(prior filmname)
9 and instr('abc', substr(filmname, -1)) > 0
10 and instr('abc', substr(prior filmname, -1)) > 0
11 and substr(filmname, 1, length(filmname) - 1) =
12 substr(prior filmname, 1, length(prior filmname) - 1)
13 and filmname > prior filmname
14 order by dbms_random.value)
15 )
16 select substr(replace(a.path, '|') || b.path, 2) filnmaes
17 from (select path_cnt, sys_connect_by_path(path, '|') path
18 from tmp
19 where connect_by_isleaf = 1
20 start with rn = 1
21 connect by rn = prior rn + 1
22 and path_cnt < 8) a, tmp b
23 where a.path_cnt + b.cnt = 8
24 and a.path_cnt < b.path_cnt
25 and rownum = 1;
未选定行
SQL> ed
已写入 file afiedt.buf
1 with tmp as
2 (select rownum rn, sum(cnt) over(order by rownum) path_cnt, path, cnt
3 from (select sys_connect_by_path(filmname, ',') path, level cnt
4 from t_film
5 where connect_by_isleaf = 1
6 start with substr(filmname, -1) = 'a'
7 or instr('abc', substr(filmname, -1)) = 0
8 connect by length(filmname) = length(prior filmname)
9 and instr('abc', substr(filmname, -1)) > 0
10 and instr('abc', substr(prior filmname, -1)) > 0
11 and substr(filmname, 1, length(filmname) - 1) =
12 substr(prior filmname, 1, length(prior filmname) - 1)
13 and filmname > prior filmname
14 order by dbms_random.value)
15 )
16 select substr(replace(a.path, '|') || b.path, 2) filnmaes
17 from (select path_cnt, sys_connect_by_path(path, '|') path
18 from tmp
19 where connect_by_isleaf = 1
20 -- start with rn = 1
21 connect by rn = prior rn + 1
22 and path_cnt < 8) a, tmp b
23 where a.path_cnt + b.cnt = 8
24 and a.path_cnt < b.path_cnt
25* and rownum = 1
SQL> /
FILNMAES
--------------------------------------------------------------------------------
别拿自己不当干部,三分钟先生,彩票也疯狂,嬉戏江湖,侏罗纪公园i,冰河世纪2a,冰河世纪2
b,神枪手智多星
SQL> |
|