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 Query for 3rd Largest
00:00
5 left

SQL Query for 3rd Largest

MediumSQL · PostgreSQL

Problem

The Airtel Thanks analytics team wants to identify subscribers with the third-highest total mobile data consumption for January 2026. Write a PostgreSQL query that aggregates usage for active subscribers and ranks distinct usage totals.

Requirements

  1. Join subscribers, active subscriptions, Airtel plans, and usage sessions.
  2. Sum each active subscriber's January 2026 data usage in MB, treating subscribers with no usage as zero.
  3. Return every subscriber tied at the third-highest distinct usage total. Use a window function rather than LIMIT and OFFSET.
  4. Return customer_id, customer_name, plan_name, and total_data_mb, ordered by customer_id.

Schema

customers
ColumnTypeDescription
customer_idPKINTUnique Airtel subscriber identifier
customer_nameVARCHAR(100)Subscriber display name
account_statusVARCHAR(20)Current account state
subscriptions
ColumnTypeDescription
subscription_idPKINTUnique subscription identifier
customer_idINTReferences customers.customer_id
plan_idINTReferences plans.plan_id
subscription_statusVARCHAR(20)Current subscription state
plans
ColumnTypeDescription
plan_idPKINTUnique Airtel plan identifier
plan_nameVARCHAR(100)Commercial name of the Airtel plan
usage_sessions
ColumnTypeDescription
session_idPKINTUnique data usage session identifier
customer_idINTReferences customers.customer_id
data_mbINTData consumed during the session in MB
usage_dateDATEDate on which the data was consumed
usage_typeVARCHAR(30)Network usage classification
Tablescustomerssubscriptionsplansusage_sessions
Interviewer

Your question is SQL Query for 3rd Largest. Start with the requirements and the four 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.