Users by Country
How many users are registered from each country?
- Aggregation
- Sorting
Challenge brief
Understand the request
International Growth is prioritising which countries to expand Google services in and needs a user count breakdown by country.
Return country, user_count in the declared deterministic order.
Return
- country
- user_count
Constraints
- Return one row per country
- Order by country name
Data you will use
Review the relevant tables before deciding how to join, filter, or aggregate them.
users
user_idINTEGERcountryVARCHAR(50)device_typeVARCHAR(20)signup_dateDATE
Hints, when you need them
Open one clue at a time so you still do the reasoning.
Hint 1
Country is the reporting grain.
Hint 2
Count user rows within each country group.
Hint 3
Finish with a stable country-name order.
Verified SQL answer
Attempt the problem first, then compare structure and reasoning—not just syntax.
Reveal solution and explanation
SELECT country, COUNT(*) AS user_count FROM users GROUP BY country ORDER BY countryWhy this works
GROUP BY country creates one group per country. COUNT(*) counts users in each group. The result has 12 rows — one per distinct country in the dataset.
Success check
Returns the complete deterministic result for users by country
Expected result
Use this output to verify values, aliases, ordering, and row count.
| country | user_count |
|---|---|
| Australia | 1 |
| Brazil | 1 |
| Canada | 3 |
| France | 1 |
| Germany | 2 |
| India | 3 |
| Italy | 1 |
| Japan | 1 |
| Mexico | 1 |
| Spain | 1 |
Previewing 10 of 12 expected rows. Run the query in the editor to inspect the full result.
Learn the concepts behind this answer
Strengthen your understanding with these targeted learning topics:
Continue practicing
Explore related company challenges
Meta
Independent Meta-style social-product, engagement, content, community, messaging, and advertising SQL practice.
Microsoft
Independent Microsoft-style cloud, productivity, subscription, usage, support, and customer analytics SQL practice.
Netflix
Independent Netflix-style streaming, subscription, catalog, ratings, and engagement SQL practice.
Return to the complete interview preparation experience.