Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
calvinfoo
Posting Yak Master
129 Posts |
Posted - 2011-12-12 : 03:22:44
|
| Dear Gurus,http://www.sqlteam.com/article/more-trees-hierarchies-in-sqlI used the same method as in the article in my Org Chart, about 500 employees, with depth of 5 maximum. It works great.With some slight modification, this is what my table looks like:USE [AMBU_ALEAVE]GO/****** Object: Table [dbo].[Tree] Script Date: 12/12/2011 15:25:25 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE TABLE [dbo].[Tree]( [SupervisorEmpID] [nvarchar](50), [UserEmpID] [nvarchar](50), [Depth] [tinyint] NULL, [Lineage] [nvarchar](255))I am a bit stucked right now when I try to further than what it shows:I want to get know the below:@EmpID1. The direct boss:SELECT * FROM tree WHERE EmpID = @empID2. The direct Subordinate:SELECT * FROM tree WHERE SupervisorEmpID = @empIDThe above two questions simple, but below questions I am rather still clueless how am I supposed to do that.3. Select all Supervisors directly above this EmpID.- If the direct Supervisor is not available, can escalate to higher Superior for the Leave Application4. Select all peers same as this EmpID under the same direct Supervisor.- If the EmpID on Sick Leave, the peers can assist to submit the Sick Leave5. Select all (direct or indirect) subordinates under this EmpID.Thanks in advance! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
sunnyleoneo
Starting Member
19 Posts |
|
|
|
|
|