Katkat

Compute unread and multi-account user percentages

MetaData Scientist · Technical Screen

Last updated

This question evaluates understanding of SQL data manipulation skills such as aggregations, joins, NULL handling, deduplication reasoning, and user- versus person-level computations for accurate percentage metrics.

You’re given two tables. Write ANSI-SQL to answer parts (a)–(d). Treat a notification as unread if read_at IS NULL. Denominator for user-level percentages is all user_ids present in people_users (include users with zero notifications).

Schema and small samples:

people_users

person_iduser_id
110
111
220
330
440
441

notifications

notification_iduser_idcreated_atread_atnotification_type
100102025-08-30 10:00:00NULLmessage
101102025-08-31 12:00:002025-08-31 12:30:00mention
102112025-09-01 08:00:00NULLmessage
103202025-09-01 09:00:002025-09-01 09:05:00follow
104302025-08-28 15:00:00NULLmessage
105412025-08-29 17:00:002025-08-29 17:02:00like

Tasks: (a) What percentage of users have at least one unread notification right now? Return both numerator, denominator, and percentage with 2 decimals. (b) Break (a) down by notification_type (i.e., percentage of users who have ≥1 unread of each type). Users may appear in multiple types; report each type’s numerator, denominator, and percentage. (c) What percentage of persons (distinct person_id) have multiple accounts (>1 user_id)? Report both the percent of persons with multiple accounts and the percent of user_ids that belong to such multi-account persons. (d) Make your queries robust to duplicate rows in notifications (e.g., same notification_id accidentally logged twice). Explain your deduping assumption briefly in a SQL comment.