SQL SORTING and FILTERING on HR Database: Display the country ID and number of cities in that country we have
SQL SORTING and FILTERING on HR Database: Exercise-25 with Solution
25. Write a query in SQL to display the country ID and number of cities in that country we have.
Sample table : locations
SELECT country_id, COUNT(*) FROM locations GROUP BY country_id;
country_id | count ------------+------- CH | 2 " | 1 US | 4 AU | 1 IT | 2 Ox | 1 JP | 2 CA | 2 DE | 1 NL | 1 SG | 1 CN | 1 UK | 2 IN | 1 BR | 1 (15 rows)
Contribute your code and comments through Disqus.
Previous: Write a query in SQL to display job ID for those jobs that were done by two or more for more than 300 days.
Next: Write a query in SQL to display the manager ID and number of employees managed by the manager.
What is the difficulty level of this exercise?