12 lines
492 B
SQL
12 lines
492 B
SQL
/*21. Write a query in SQL to display the country name, city, and number of those departments where at leaste 2 employees
|
|
are working.*/
|
|
SELECT country_name,city, COUNT(department_id)
|
|
FROM countries
|
|
JOIN locations USING (country_id)
|
|
JOIN departments USING (location_id)
|
|
WHERE department_id IN
|
|
(SELECT department_id
|
|
FROM employees
|
|
GROUP BY department_id
|
|
HAVING COUNT(department_id)>=2)
|
|
GROUP BY country_name,city; |