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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Get started
Top 5% Daily Active Users
00:00
5 left

Top 5% Daily Active Users

HardSQL · PostgreSQL

Problem

Write a SQL query to identify the top 5% of users based on daily active usage over the last quarter at Okta.

Treat daily active usage as the number of distinct calendar days on which each user generated usage. Use the users and usage_events tables, and include users with no qualifying activity when determining the percentile.

Output

  1. One row per qualifying user with user_id, user_name, active_days, and usage_rank
  2. Include users in the top 5%, including ties at the cutoff
  3. Sort by active_days descending, then user_id ascending

Schema

users
ColumnTypeDescription
user_idPKINTUnique Okta user identifier
user_nameVARCHAR(100)User display name
emailVARCHAR(255)User email address
usage_events
ColumnTypeDescription
event_idPKINTUnique usage event identifier
user_idINTUser associated with the event
activity_dateDATECalendar date when usage occurred
usage_typeVARCHAR(50)Type of Okta product activity
Tablesusersusage_events
Interviewer

Your question is Top 5% Daily Active Users. 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.