现在的位置: 首页 > 综合 > 正文

oracle connect by 用法(2)

2012年08月01日 ⁄ 综合 ⁄ 共 393字 ⁄ 字号 评论关闭

SELECT  level,tc_appma001,tc_appma002,tc_appma003
  FROM whh.tc_appma_file
  start with tc_appma003=0
connect by tc_appma003 = prior tc_appma001
order by level

 

原表:

001  002     003

   1 生產排程   0   
   2 機台排程   1   
   3 原料排程   1   
   4 訂單加急   2   
   5 原料加急   4   
   6 模具加急   4   

 

之後:

level   001  002       003

 1       1    生產排程    0
 2       2    機台排程    1
 2       3    原料排程    1
 3       4    訂單加急    2
 4       6    模具加急    4

 4       5    原料加急    4

 

抱歉!评论已关闭.