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 for Past-Due Accounts
00:00
5 left

SQL for Past-Due Accounts

MediumSQL · PostgreSQL

Problem

Extra Space Storage operations managers need a location-level view of customer accounts with unpaid balances more than 30 days past their invoice due date. Using February 15, 2025 as the reporting date, write a PostgreSQL query that identifies these accounts and summarizes their exposure by store location.

Requirements

  1. Include only active accounts with a positive unpaid balance and a due date more than 30 days before the reporting date.
  2. Group results by Extra Space Storage store location.
  3. Return the number of overdue accounts, a comma-separated list of account numbers, and the total outstanding balance.
  4. Sort locations alphabetically.

Representative Data

The supplied sample data includes multiple invoices per account, fully paid invoices, a boundary due date, closed accounts, missing payments, and unmatched records.

Schema

stores
ColumnTypeDescription
store_idPKINTUnique Extra Space Storage store identifier
locationVARCHAR(100)Store city and state
customer_accounts
ColumnTypeDescription
account_idPKINTUnique customer account identifier
store_idINTStore assigned to the customer account
account_numberVARCHAR(20)Customer-facing account number
customer_nameVARCHAR(100)Customer name on the account
statusVARCHAR(20)Current account status
invoices
ColumnTypeDescription
invoice_idPKINTUnique invoice identifier
account_idINTCustomer account billed by the invoice
due_dateDATEDate payment was due
amount_dueNUMERIC(10,2)Original invoice amount
amount_paidNUMERIC(10,2)Amount paid against the invoice
Tablesstorescustomer_accountsinvoices
Interviewer

Your question is SQL for Past-Due Accounts. Start with the requirements and the three 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.