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 10% Data Usage Query
00:00
5 left

Top 10% Data Usage Query

MediumSQL · PostgreSQL

Problem

McAfee wants to identify users with the highest recent data consumption. Write a SQL query that calculates each user's total data usage during the 30-day period ending on September 15, 2026, and returns the top 10% of users.

Output

  1. One row per selected user, with columns user_id, username, total_usage_bytes, and usage_rank
  2. Include every user in the population when calculating the 10% cutoff, including users with no qualifying events, whose total is treated as zero
  3. Include events from August 17, 2026 through September 15, 2026, inclusive; ignore events outside this period and events with NULL user_id
  4. Round the cutoff up to the next whole user, so a nonempty population returns at least one user
  5. Sort by usage_rank, then user_id; rank ties deterministically by ascending user_id
  6. Rows with NULL usage_bytes contribute nothing to a user's total

Schema

users
ColumnTypeDescription
user_idPKINTUnique McAfee user identifier
usernameVARCHAR(100)User display name
emailVARCHAR(255)User email address
usage_events
ColumnTypeDescription
event_idPKINTUnique usage event identifier
user_idINTUser associated with the usage event
event_timestampTIMESTAMPTime when the data usage occurred
usage_bytesBIGINTBytes used during the event
Tablesusersusage_events
Interviewer

Your question is Top 10% Data Usage Query. 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.