2016-09-20 12 views
0

Rückkehr Ich habe ein (jetzt gründlich abgeleitet) CTE:Oracle verbinden links keine Zeilen

feature_id | function_id | group_id | subgroup_id | type_id 
1   1    null  1    null 
1   1    null  null   14 
2   1    null  5    null 
2   1    null  null   21 
3   1    null  7    null 
3   1    null  null   5 

ich die Zeilen zusammen, dies zu sammeln versuchen mit:

select C1.feature_id, C1.function_Id, C2.Group_ID, C3.Subgroup_ID, C4.Type_id 
from CTE C1 
left join CTE C2 
    on C1.feature_id = C2.feature_id 
    and c1.function_id = c2.function_id 
    and c2.group_id is not null 
left join CTE C3 
    on C1.feature_id = C3.feature_id 
    and c1.function_id = c3.function_id 
    and c3.subgroup_id is not null 
left join CTE C4 
    on C1.feature_id = C4.feature_id 
    and c1.function_id = c4.function_id 
    and c4.type_id is not null 

Das gibt mir 0 Zeilen. ..

Zur Validierung, ich lief:

select * 
from CTE C1 

236 Zeilen ausgewählt

Kann jemand helfen? Sicherlich sollten die Zeilen aus C1 zurückkommen ...

EDIT: Fest es mit der Oracle Syntax:

select C1.feature_id, C1.function_Id, C2.Group_ID, C3.Subgroup_ID, C4.Type_id 
from CTE C1, CTE C2, CTE C3, CTE C4 
where C1.feature_id = C2.feature_id(+) 
and c1.function_id = c2.function_id(+) 
and C2.group_id(+) is not null 
... 

(I hate die Oracle-Syntax)

+1

Diese nur 0 Zeilen zurückgeben sollte, wenn 'CTE' hat keine Zeilen. Sind Sie sicher, dass Sie keine Wo-Klausel haben? –

+0

@GordonLinoff Das ist, was ich dachte, aber nein – JohnHC

+1

'und c2.group_id ist nicht null' alle group_ids sind null? – artm

Antwort

0

Ok, es gelöst ... Feste mit der Oracle-Syntax:

select C1.feature_id, C1.function_Id, C2.Group_ID, C3.Subgroup_ID, C4.Type_id 
from CTE C1, CTE C2, CTE C3, CTE C4 
where C1.feature_id = C2.feature_id(+) 
and c1.function_id = c2.function_id(+) 
and C2.group_id(+) is not null 
... 

(ich hasse die Orakel-Syntax)

+0

Ich vermute, dass Sie es mit expliziter "JOIN" -Syntax beheben können, indem Sie die konstanten Bedingungen in eine Unterabfrage stellen. Ich bin jedoch nicht auf diesen Fehler gestoßen, so dass ich keine Gelegenheit hatte, einen Fix zu finden. –