Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

This problem is all about identifying all the employees directly or indirectly to whom the given Employee reports to. The challenge is to write a query that can take a Employee Id as a parameter and list all the employees to whom the Employee is reporting, directly or indirectly.

TSQL Beginners Challenge 17- Working with Employee hierarchical structures

TSQL Beginners Challenge 17- Working with Employee hierarchical structures

Sep 27 2010 10:12AM by Niladri Biswas   

Introduction

This challenge is more about processing HIERARCHIES.

The problem is all about identifying all the employees directly or indirectly to whom the given Employee reports to. The challenge is to write a query that can take a Employee Id as a parameter and list all the employees to whom the Employee is reporting, directly or indirectly.

Sample Data

EmpRecord
-----------------------------------------------------------------

  
  
  
  
  
  
  
  
  
  

If the parameter contains 9 the query should return:

Expected Results

Level Path				                        Hierarchy
----- ----------------------------------------- -----------------
0	  Jiya Devi/Deepak Kr. Goyal/Niladri Biswas	Niladri Biswas
1	  Jiya Devi/Deepak Kr. Goyal	    	      Deepak Kr. Goyal
2	  Jiya Devi	        			                Jiya Devi

Your query should ideally look like the following:

DECLARE @EmpID VARCHAR(20)
SELECT @EmpID = 9

Rules

  1. The program should run in SQL SERVER 2005+.
  2. Column names should respect the desired output shown.
  3. Result must be sorted in ascending order of Level.
  4. Hierarchy column should display parents starting from the topmost position to the child sought for.

Sample Script

Use the following script to generate the sample data.

DECLARE @Employees TABLE(EmpRecord XML)
INSERT INTO @Employees 
SELECT '
		
		
		
		
		
					
		
		
		
		
		'
SELECT * FROM @Employees

Restrictions

  1. The solution should be a single query that starts with a "SELECT" or “;WITH”.

Notes

Tags:Puzzles, TSQL Beginners Challenge, TC, TSQL Beginners Challenge 17

Niladri Biswas
7 · 21% · 6710
TSQL Beginners Challenge 17- Working with Employee hierarchical structures , 5.0 out of 5 based on 0 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]