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
Top Users by Region
00:00
5 left

Top Users by Region

EasySQL · PostgreSQL

Problem

Acumen wants to identify its most engaged users in each region. As of February 15, 2025, write a PostgreSQL query to find the top three users per region based on engagement points earned during the previous 30 days.

Requirements

  1. Include engagement events from January 16 through February 15, 2025, inclusive.
  2. Sum each user's non-null score within the period.
  3. Rank users independently within each region using ROW_NUMBER(), ordering by total score descending and user_id ascending as the tie-breaker.
  4. Return only ranks 1 through 3, with regions ordered alphabetically and users ordered by rank.

Schema

users
ColumnTypeDescription
user_idPKINTEGERUnique Acumen user identifier
user_nameVARCHAR(100)User display name
regionVARCHAR(50)User geographic region
engagement_events
ColumnTypeDescription
event_idPKINTEGERUnique engagement event identifier
user_idINTEGERReferences users.user_id
event_atTIMESTAMPTimestamp when the engagement occurred
event_typeVARCHAR(50)Type of engagement action
scoreNUMERIC(10,2)Points assigned to the event
Tablesusersengagement_events
Interviewer

Your question is Top Users by Region. Start with the requirements and the two 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.