Direct/ Indirect employees reporting a manager and direct/ indirect managers of an employee

 DROP TABLE IF EXISTS [employee]


CREATE TABLE [employee]

(

[ID] int,

[Name] varchar(100),

[Manager_ID] int

)


INSERT INTO [employee]

VALUES

(1,'Rohit',10),

(2,'Rahul',10),

(3,'Ravi',10),

(4,'Shiva',20),

(5,'Sai',20),

(6,'Sumit',20),

(10,'Priya',100),

(11,'Riyaz',100),

(12,'Nitin',100),

(20,'Yash',100),

(22,'Arjun',100),

(100,'Naveen',NULL),

(50,'Nikhil',1),

(60,'Akhil',1)


SELECT * FROM employee

Comments

Popular posts from this blog

50 Essential SQL Questions to Land Your Dream Job

How to find all the customers who placed orders on three consecutive days | SQL Scenario questions

ACCENTURE SQL INTERVIEW QUESTION | Change the ProductIDs