回路は2つの終点(脚)を持ち、各脚はデバイスに接続されています。オラクルオーダーby:対称的な結果の注文
component location pathelement
-------------------------------
device_A A A_DD1
device_A A A_DD2
device_A A A_DD3
leg_A L_A A_LL1
leg_A L_A A_LL2
circuit Center CCCC
leg_B L_B B_LL1
leg_B L_B B_LL2
device_B B B_DD2
device_B B B_DD3
:その結果、各側の回路に対称はAとB が、私は以下のように私のSQLの結果をソートするために探していますと言っています。 私のクエリは次のとおりです。
select component,location,pathelement,sortorder from
(select c.name circuit,l.name leg,d.name d,
c.location c_loc,l_pe.location l_loc,d_pe.location d_loc,
c_pe.pathelements c_pe,l_pe.pathelements l_pe,d_pe.pathelements d_pe,
1 d_sortorder,2 l_sortorder,3 c_sortorder
from circuit c,leg l,device d,
(select circuitid,location,pathelements from circuit_details) c_pe,
(select legid,location,pathelements from leg_details)l_pe,
(select deviceid,location,pathelements from device_details)d_pe
where
c.circuit2leg=l.legid(+)
and l.leg2device=d.deviceid(+)
and c.circuitid=c_pe.circuitid(+)
and l.legid=l_pe.legid(+)
and d.deviceid=d_pe.deviceid(+)
and c.name=<some_text>)
Unpivot((component,location,pathelement,sortorder) for c in
((circuit,c_loc,c_pe,c_sortorder),(leg.l_loc,l_pe,l_sortorder),(device,d_loc,d_pe,d_sortorder))) order by sortorder;
実際の出力は:
component location pathelement
-------------------------------
device_A A A_DD1
device_A A A_DD2
device_A A A_DD3
device_B B B_DD2
device_B B B_DD3
leg_A L_A A_LL1
leg_A L_A A_LL2
leg_B L_B B_LL1
leg_B L_B B_LL2
circuit Center CCCC
あなたは4列を選択し、だけ私たちにそれらの3を示しました。あなたが注文したものが欠落しています... – jarlh
Cの項目を追加したらどうなるでしょうか? – jarlh
あなたの例ではleg_Aを見逃しませんか? –