Google-style Company ChallengeEasyVerified answerSQLite live

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_idINTEGER
  • countryVARCHAR(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 country

Why 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.

countryuser_count
Australia1
Brazil1
Canada3
France1
Germany2
India3
Italy1
Japan1
Mexico1
Spain1

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

SQL Interview Practice

Return to the complete interview preparation experience.