Question

The Employee table consists of the following data fields: Employee ID, Employee Name, Employee Department, Employee...

The Employee table consists of the following data fields: Employee ID, Employee Name, Employee Department, Employee Manager (EMP_ID of the Employee to whom the employee reports) and Employee DOH (Date of Hire). Using the following data table, answer the questions with appropriate SQL queries.

EMP_ID

EMP_NAME

EMP_DEPT

EMP_MANAGER

EMP_DOH

1

John

IT

9

05-08-2010

2

Alex

Finance

0

06-03-2008

3

Linda

IT

9

07-02-2010

4

Robin

Purchase

8

08-12-2010

5

Maki

Purchase

8

09-08-2012

6

Ross

Sales

7

10-05-2012

7

Reiki

Sales

2

11-02-2009

8

Anna

Sales

2

12-08-2011

9

Jena

IT

2

01-01-2008

10

Bonny

IT

9

01-01-2008

Find the manager with the most reportees.

List managers who joined after all their reportees.

  Which department has the most managers, and how many?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1)

SELECT M.* FROM EMPLOYEE E, EMPLOYEE M WHERE E.EMP_MANAGER = M.EMP_ID GROUP BY M.EMP_ID ORDER BY COUNT(*) DESC LIMIT 1;

2)

SELECT * FROM EMPLOYEE M WHERE EMP_DOH > (SELECT MAX(EMP_DOH) FROM EMPLOYEE E WHERE E.EMP_MANAGER = M.EMP_ID);

3)

SELECT EMP_DEPT, COUNT(DISTINCT EMP_MANAGER) FROM EMPLOYEE GROUP BY EMP_DEPT;

Add a comment
Know the answer?
Add Answer to:
The Employee table consists of the following data fields: Employee ID, Employee Name, Employee Department, Employee...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • MICROSOFT SQL SERVER - Create the following views 1.List the employee assigned to the most projects...

    MICROSOFT SQL SERVER - Create the following views 1.List the employee assigned to the most projects 2.List the project with the most hours SCRIPT TO BUILD DATABASE create table department ( dept_ID int not null , dept_name char(50) NOT NULL, manager_ID int not null, manager_start_date date not null, constraint Dept_PK primary key (dept_ID), constraint D_Name_AK unique (dept_name) ); insert into department values(1,'abc',1,'2019-01-08'); insert into department values(2,'abc2',2,'2019-01-08'); insert into department values(3,'abc3',2,'2019-01-08'); insert into department values(4,'abc4',2,'2019-01-08'); /*project table done*/ create table project...

  • The employee is table, the best candidate for primary key is Select one: a. Department ID...

    The employee is table, the best candidate for primary key is Select one: a. Department ID b. Employee hiredate c. Employee ID d. Employee salary Question 2 A primary key can be composed of more than one attribute. Select one: True False Question 3 A foreign key allows you to join two tables. Select one: True False Question 4 Given two tables, department (dept_id, dept_location, dept_name) and EMPLOYEE(emp_id, emp_name, emp_dept_id, emp_name, emp_salary), which attribute (column) is the foreign key? Select...

  • Please help me answer the following questions regarding data relationship tables. Employee ID First Name Last...

    Please help me answer the following questions regarding data relationship tables. Employee ID First Name Last Name email Title Address Extension Department Department ID Hiring Date Department Phone # 0001 John Smith jsmith Accountant 1300 West st 5775 Accounting 2100 8/1998 407-366-5700 0002 Brian Miller badams Admin Assistant 1552 Palm dr 5367 Human resource 2300 4/1995 407-366-5300 0003 James Miller miller Inventory Manager 2713 Buck rd 5432 Production 2520 8/1998 407-366-5400 0004 John Jackson jackson_sam Sales Person 433 tree dr...

  • The following ERD and two tables represent a partial model similar to what we used in...

    The following ERD and two tables represent a partial model similar to what we used in class. Answer all questions by writing SQL syntax to solve each. If a question requires more time, please move on to the next. Employee EmpNo (PK) Ename Job ManagerID HireDate Salary Commission DeptNo (FK) Department DeptNo Dname Location 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON Department DeptNo (PK) Dname Location 1400 Employee Monthly EmpNo Ename Job ManagerID HireDate...

  • Create a procedure to update the sales history table following the requirements below. A table creation...

    Create a procedure to update the sales history table following the requirements below. A table creation script is provided below. a) Call the procedure: UPDATE_SALES_HISTORY (The procedure name is important for our scripts to test and grade your code; please do not rename it (otherwise our scripts will not run and your score will be 0). b) The procedure takes 2 parameters: (4-digit-year, 2-digit-month). Both parameters will be numeric, e.g., (2019, 11) will denote 2019 (year) and November (month). The...

  • Can somone please help me with the journal entries? Required information (The following information applies to...

    Can somone please help me with the journal entries? Required information (The following information applies to the questions displayed below.] Wally's Widget Company (WWC) incorporated near the end of 2011. Operations began in January of 2012. WWC prepares adjusting entries and financial statements at the end of each month. Balances in the accounts at the end of January are as follows: Cash $20,420 Unearned Revenue (35 units) $ 4,950 Accounts Receivable Allowance for Doubtful Accounts Inventory (40 units) $ 11,450...

  • Super stuck on a couple of questions on this scenario. Advanced Scenario 7: Mark and Barbara...

    Super stuck on a couple of questions on this scenario. Advanced Scenario 7: Mark and Barbara Matthews Directions Using the tax software, complete the tax retum, including Form 1040 and all appropri- ate forms, schedules, or worksheets. Answer the questions following the scenario. Note: When entering Social Security numbers (SSNS) or Employer identification Numbers (EINS), replace the Xs as directed, or with any four digits of your choice. Interview Notes • Mark and Barbara are married and want to file...

  • Question Help regarding the new mache o e Heavenly Candy Company is considering purchasing a second...

    Question Help regarding the new mache o e Heavenly Candy Company is considering purchasing a second chocolate dipping machine in order to expand their business. The information Heavenly has com BB Cack the icon to view the information) Present Value of $1 table Present Value of Annuity of $1 table Future Value of $1 table Future Value of Anuty of table Read the requirements Requirement 1. Calculate the following for the new machine: a. Net present value (NPV) (Use factors...

  • CASE 20 Enron: Not Accounting for the Future* INTRODUCTION Once upon a time, there was a...

    CASE 20 Enron: Not Accounting for the Future* INTRODUCTION Once upon a time, there was a gleaming office tower in Houston, Texas. In front of that gleaming tower was a giant "E" slowly revolving, flashing in the hot Texas sun. But in 2001, the Enron Corporation, which once ranked among the top Fortune 500 companies, would collapse under a mountain of debt that had been concealed through a complex scheme of off-balance-sheet partnerships. Forced to declare bankruptcy, the energy firm...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT