May 22, 2014 at 9:30 am
Hi,
I have couple of tables
1. Entity
with the structure as below
EntityId [Description] ParentEntityId
1 UK NULL
2 England 1
3 Midlands 2
4 101 (EmpId) 3
5 102 3
2. Person
With the structure as below
PersonId PersonName
1 ABCXYZ
2 XXXXXX
3. EntityPerson
With the structure as below
EntityPersonId EntityId PersonId
1 4 1
2 5 2
I would like to write a query to display hierarchy horizontally.
Sample output
101 Midlands England UK ABCXYZ
102 Midlands England UK XXXXXX
Can anyone suggest the query?
May 22, 2014 at 9:44 am
How about an article that shows a recursive CTE in use. It should help you understand it better than just getting a query to do the task.
http://jasonbrimhall.info/2010/02/13/payperiod-ii/
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
May 22, 2014 at 9:47 am
does this help.....??
http://www.sqlservercentral.com/Forums/FindPost1517185.aspx
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
May 22, 2014 at 9:56 am
J Livingston SQL (5/22/2014)
does this help.....??
That is an eerily similar thread
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply