megs
9/20/2019 - 3:47 PM

Client Tree with Client Names Joined

--Client Tree script with client names joined on clientID, alphaClientID, parentClientID, and entryClientID.

select 
	ct.clientID, 
	c1.clientName as 'Client Name', 
	ct.parentclientID, 
	c2.clientName as 'Parent Client Name',
	ct.alphaClientID,
	c3.clientName as 'Alpha Client Name',  
	ct.entryClientID,
	c4.clientName as 'Entry Client Name' 
from clienttree ct with (nolock)
	join client c1 with (nolock) on ct.clientID = c1.clientID
	join client c2 with (nolock) on ct.parentclientID = c2.clientID
	join client c3 with (nolock) on ct.alphaClientID = c3.clientID
	join client c4 with (nolock) on ct.entryClientID = c4.clientID