Skip to content

Instantly share code, notes, and snippets.

@radityopw radityopw/cte_i.sql
Created Feb 29, 2016

What would you like to do?
USE AdventureWorks2012;
with my_employee as (
select employeeid,firstname,lastname,title, cast('' as varchar) as manager
from dbo.MyEmployees
where managerId is null
union all
select a.employeeid,a.firstname,a.lastname,a.title, cast(b.firstname+' '+b.lastname+' '+b.title as varchar) as manager
from dbo.MyEmployees a inner join
my_employee b on a.managerid = b.employeeid
select * from my_employee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.