Bonjour à tous,
Je possède une table d'organisation possédant un Id et un Id père.
Je cherche à ressortir de cette table tous les fils à partir d'un nœud père.
Pour ça c'est ok, j'ai ce qu'il me faut.
Par contre maintenant j'ai besoin d'exclure de cette hiérarchie tous les fils d'un certain nœud.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 with Organisation (OrganisationId, Name) AS ( select OrganisationId, Name from Common.DimOrganisation where Name in ('Noeud1', 'Noeud2') UNION ALL select orgPere.OrganisationId, orgPere.Name from Common.DimOrganisation orgPere JOIN Organisation tree ON tree.OrganisationId = orgPere.OrganisationFatherId ) select * from Organisation
Il doit bien y avoir une méthode plus intéressante que le "not in" avec une autre CTE... ?
Merci à vous.
Partager