TCS SQL INTERVIEW QUESTION | Manager with second most employees

 DROP TABLE IF EXISTS employee


CREATE TABLE employee (

    id INT ,

    name VARCHAR(100),

    department VARCHAR(100),

    managerid INT 

);

 

INSERT INTO employee (id,name, department, managerid) VALUES 

(1,'John Smith', 'Engineering', NULL),

(2,'Sarah Johnson', 'Sales', NULL),

(3,'Michael Brown', 'HR', NULL),

(4,'Emily Davis', 'Engineering', 1),

(5,'James Wilson', 'Engineering', 1),

(6,'Linda Martinez', 'Engineering', 1),

(7,'David Lee', 'Sales', 2),

(8,'Karen Taylor', 'HR', 3),

(9,'Charles Anderson', 'HR', 3);


 


 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