Hierarchy of Employee “names” with CTE: Cannot create a correct version
-
02-11-2019 - |
Question
I am trying to create the correct structure of my sql (CTE) query, but I can not. This is a version I want to have .
And this is my current version: . As you can see there are duplicates and i have no idea how to get rid of them. Futhermore the structure is wrong. I already tried to look for solutions like here but was unable to come up with solution. CTE query doesn't print the right structure?
My Employee table looks like this http://sqlfiddle.com/#!6/428d2/2
Here is my SQL query I use to create the correct name column: http://sqlfiddle.com/#!6/bf4c1/4
I use MsSQL 2012, so feel free to use newest fuctions etc. Any help appreciated.
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange