7. Using only the Employee table, write a SQL query to retrieve the names of all
ID: 3839434 • Letter: 7
Question
7. Using only the Employee table, write a SQL query to retrieve the names of all the cities with more than twelve employee, along with the number of employees in each of these cities.
The following data samples show a few rows from each table. For the questions that follow, assume that each table contains many more rows than are shown here. employee ID employeeFirstName employee LastName employee HomeCity employeeHomeState Smith Boston MA 1 John 2 Jane Boston MA NY Johnson 3 Sue New York Johnson New York 4 Tim Employee employerCity employer State employerID employer Name CA 1 Stark Industries Los Angeles 2 Initech Newark NJ CA Los Angeles 3 Acme Corporation NY 4 Wayne Enterprises New York City Employer employee Employerl employeelD employerlD date Hired 11 4 2005-08-05 22 2007-04-02 33 1 2006-05-09 4 1 2005- 11-25 EmployeeEmployerExplanation / Answer
QUERY :
SELECT DRV.employeeHomeCity, DEV.emp_count
FROM (SELECT employeeHomeCity,count(employeeID) emp_count
FROM Employee
GROUP BY employeeHomeCity
) DRV
WHERE DRV.emp_count > 12;
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.