某产品加工工序
当前工序,下个工序
A05,A06
A06,A07
A10,A11
A11,A12
A12,A05 用oracle-sql,求工序的顺序清单
>>> sort >>
A10
A11
A12
A05
A06
A07
当前工序,下个工序
A05,A06
A06,A07
A10,A11
A11,A12
A12,A05 用oracle-sql,求工序的顺序清单
>>> sort >>
A10
A11
A12
A05
A06
A07
调试欢乐多
-------------------- --------------------
A05 A06
A06 A07
A10 A11
A11 A12
A12 A05SQL> select aaa
2 from test
3 start with aaa=(
4 select aaa
5 from test
6 where aaa not in(select bbb from test))
7 connect by prior bbb=aaa
8 union all
9 select bbb
10 from test
11 where bbb not in(select aaa from test);AAA
--------------------
A10
A11
A12
A05
A06
A07已选择6行。
我今天就确认。
-------------------- --------------------
A05 A06
A06 A07
A10 A11
A11 A12
A12 A05 SQL> select *
2 from t1
3 start with curr_id = (select curr_id
4 from t1
5 where rownum = 1
6 and curr_id not in (
7 select prev_id
8 from t1
9 )
10 )
11 connect by curr_id = prior prev_id;CURR_ID PREV_ID
-------------------- --------------------
A10 A11
A11 A12
A12 A05
A05 A06
A06 A07