小编use*_*436的帖子

遍历Oracle的每个ID遍历完整路径

我有一个输入数据,包括ID,prev,current和next节点(未排序).我必须在每个ID的第一页和最后一页之间找到一条路径,该路径覆盖所有遍历的节点.例如:如果我的输入数据是这样的:第一列是ID,第二列是prev_node,第三列是当前节点,第四列是下一个节点.对于起始值,Prev_node将为空,而对于最后一个值,下一个节点将为空

输入

id prev current next
1 a b c
1 a e f
1 a b g
1 a b o
1 b c d
1 b g h
1 b o p
1 c d a
1 c b g
1 d a e
1 e f e
1 e f f
1 f e f
1 f f f
1 f f a
1 f a b
1 g h i
1 h i j
1 h …

sql database oracle plsql stored-procedures

10
推荐指数
1
解决办法
353
查看次数

计算两个字符串oracle中的顺序匹配单词

我想要一个查询,返回两个字符串中的单词的顺序匹配数量示例:

Id  column1               column2     result   
1   'foo bar live'        'foo bar'       2  
2   'foo live tele'       'foo tele'      1  
3   'bar foo live'        'foo bar live'  0 
Run Code Online (Sandbox Code Playgroud)

获取我正在使用的总发生次数:

select id, column1,column2,
extractvalue(dbms_xmlgen.getxmltype('select cardinality (
  sys.dbms_debug_vc2coll(''' || replace(lower(column1), ' ', ''',''' ) || ''') multiset intersect
  sys.dbms_debug_vc2coll('''||replace(lower(column2), ' ', ''',''' )||'''))  x from dual'), '//text()') cnt
from table.
Run Code Online (Sandbox Code Playgroud)

任何人都可以建议在类似的行上查询顺序匹配,因为我想要连续匹配的数量和一起显示的出现次数.

sql oracle stored-procedures

8
推荐指数
1
解决办法
904
查看次数

如果存在,则显示匹配记录的SQL显示所有记录

我想编写一个SQL查询来显示匹配的行(如果存在),否则显示所有记录.

示例: - 输入数据: -

ID

1

2

3

4

select * from table where id = 2 /* since id exits it should return id o/p 2 */


select * from table where id = 8/* since id doesn't exist it should return all the rows of table) 
Run Code Online (Sandbox Code Playgroud)

即o/p

1

2

3

4

我想在SQL中严格执行此操作,不需要PL/SQL或任何编程块

sql oracle

0
推荐指数
1
解决办法
1912
查看次数

标签 统计

oracle ×3

sql ×3

stored-procedures ×2

database ×1

plsql ×1