Recursive CTE while Parent Id not in a List
问题 I have the following Nested Set That results in this tree 1 - |---- 2 - | |---- 4 - | |---- 7 | |---- 8 |----10 - |---- 9 3 - |---- 5 |---- 6 13- |---- 11 |---- 12 I have a list of produts SELECT Id, Name ... FROM Products A many-to-many relationship with the categories. All Categories can have Promotions. Ok now the problem. Let's say I have a ProductX in the categories 7,8,6. And Promotions in the categories 1,2,3. I need get the closest parent with a promotion per category or until there