Google-style Company ChallengeBeginnerVerified answerSQLite live

Users by Device Type

How many users registered on each type of device?

  • Aggregation
  • Sorting

Challenge brief

Understand the request

Device Strategy needs the registered-user device mix for product planning.

Return device_type, user_count in the declared deterministic order.

Return

  • device_type
  • user_count

Constraints

  • Return one row per device type
  • Order by user count descending, then device type

Data you will use

Review the relevant tables before deciding how to join, filter, or aggregate them.

users

  • device_typeVARCHAR(20)

Hints, when you need them

Open one clue at a time so you still do the reasoning.

Hint 1

Device type is stored on each registered user.

Hint 2

Count users within each device group.

Hint 3

Use device type to stabilize equal group sizes.

Verified SQL answer

Attempt the problem first, then compare structure and reasoning—not just syntax.

Reveal solution and explanation
SELECT device_type, COUNT(*) AS user_count FROM users GROUP BY device_type ORDER BY user_count DESC, device_type

Why this works

23 users split across 3 device types: 12 mobile (52%), 7 desktop (30%), 4 tablet (17%). Single-table GROUP BY — the simplest aggregation pattern.

Success check

Returns the complete deterministic result for users by device type

Expected result

Use this output to verify values, aliases, ordering, and row count.

device_typeuser_count
mobile13
desktop7
tablet4

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.