oracle level關鍵字
阿新 • • 發佈:2019-01-03
SQL> select Cow,Bull,LPAD(' ',6*(Level-1))||Offspring As
Offspring,Sex,Birthdate from BREEDING start with Offspring =
'BANDIT' connect by BULL = PRIOR Offspring;
COW BULL
OFFSPRING
SEX BIRTHDATE
------ ------ ------------------------------ ---
------------
BANDIT
M
SUZY BANDIT
DELLA
F
11-10月-08
MANDY BANDIT
DUKE
M
24-7月 -04
GINNY DUKE
RUTH
F 25-12月-06
GINNY DUKE
SUZY
F 03-4月 -06
BETSY BANDIT
GINNY
F
04-12月-03
EVE BANDIT
GRETA
F 12-3月 -01
BETSY BANDIT
TEDDI
F
12-8月 -05
已選擇8行。
SQL> select Cow,Bull,LPAD(' ',6*(Level-1))||Offspring As
Offspring,Sex,Birthdate from BREEDING start with Offspring =
'BETSY' connect by Cow = PRIOR Offspring;
COW BULL
OFFSPRING
SEX BIRTHDATE
------ ------ ------------------------------ ---
------------
EVE ADAM
BETSY
F 02-1月
-00
BETSY BANDIT
GINNY
F
04-12月-03
GINNY DUKE
RUTH
F 25-12月-06
GINNY DUKE
SUZY
F 03-4月 -06
SUZY BANDIT
DELLA
F
11-10月-08
BETSY ADAM
NOVI
F 30-3月 -03
BETSY BANDIT
TEDDI
F
12-8月 -05
已選擇7行。