A medium SQL interview practice problem on DataDriven. Write and execute real sql code with instant grading.
- Domain
- SQL
- Difficulty
- medium
- Seniority
- L5
Problem
Our infrastructure inventory uses hostnames that share prefixes. Count unique hostnames per region, using only the first word of the hostname (case insensitive), so entries like 'web-server-01' and 'Web-server-02' share the same prefix. If reversed forms exist (like 'prod-db' and 'db-prod'), count them as the same. Return results by count descending, then region ascending.
Summary
How many distinct machines live in each region?
Practice This Problem
Solve this SQL problem with real code execution. DataDriven runs your SQL queries against a real database and grades it automatically.