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
Ranking Users From Usage Logs
00:00
5 left

Ranking Users From Usage Logs

MediumSQL · PostgreSQL

Problem

Parse through this dictionary with usage logs on a certain software and rank the top users based on screen time, active user status, and page views.

Use the user dictionary and usage logs for the software named Foundry. Consider only users marked active. Return the three highest-ranked users, using page views as the tie-breaker after screen time.

Output

  1. One row per qualifying active user with user_id, username, is_active, total_screen_time, total_page_views, and user_rank
  2. Include only users with a rank of 3 or better
  3. Sort by user_rank ascending, then user_id ascending

Schema

user_dictionary
ColumnTypeDescription
user_idPKINTUnique user identifier
usernameVARCHAR(100)User display name
is_activeBOOLEANWhether the user is currently active
usage_logs
ColumnTypeDescription
log_idPKINTUnique usage-log identifier
user_idINTUser associated with the usage event
software_nameVARCHAR(100)Software associated with the usage event
screen_time_minutesINTMinutes spent using the software
page_viewsINTNumber of pages viewed
Tablesuser_dictionaryusage_logs
Interviewer

Your question is Ranking Users From Usage Logs. 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.