Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
SQL Top Users by Region
00:00
5 left

SQL Top Users by Region

MediumSQL · PostgreSQL

Problem

Acumen wants to identify its most engaged users in each region. Write a PostgreSQL query that calculates engagement scores from recent Acumen activity and returns the top three ranks per region, preserving ties.

Use 2026-08-29 12:00:00+00 as the report timestamp so the result is reproducible. The reporting window includes events from the preceding 30 days, including the timestamp boundary.

Requirements

  1. Join users to engagement events and event types to calculate each user's score.
  2. Assign points from event_types.points and treat users with no scored activity as having a score of zero.
  3. Rank users independently within each region using a tie-aware window function.
  4. Return every user whose rank is at most 3, including all users tied at the third rank.
  5. Order results by region, rank, and user ID.

Representative data

Schema

users
ColumnTypeDescription
user_idPKINTUnique Acumen user identifier
user_nameVARCHAR(100)User display name
regionVARCHAR(50)User's geographic region
engagement_events
ColumnTypeDescription
event_idPKINTUnique engagement event identifier
user_idINTUser who generated the event
event_type_idINTType of engagement event
occurred_atTIMESTAMPTZTimestamp when the event occurred
event_types
ColumnTypeDescription
event_type_idPKINTUnique event type identifier
event_nameVARCHAR(50)Human-readable event name
pointsINTEngagement points awarded for the event
Tablesusersengagement_eventsevent_types
Interviewer

Your question is SQL Top Users by Region. Start with the requirements and the three tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.