Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
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 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
Build my plan
Early Loan Payment Completion
00:00
5 left

Early Loan Payment Completion

MediumSQL · PostgreSQL

Problem

Write a SQL query to identify members who have completed their loan payments ahead of schedule on Happy Money.

Use the members, loans, and loan_payments tables. Consider only completed loans and posted payments. Treat the latest posted payment date as the actual completion date.

Output

  1. One row per qualifying member with member_id, member_name, ahead_of_schedule_loans, and max_days_ahead
  2. Include only members with at least one completed loan paid before its scheduled end date
  3. Order by max_days_ahead descending, then member_id ascending

Schema

members
ColumnTypeDescription
member_idPKINTUnique Happy Money member identifier
member_nameVARCHAR(100)Member's display name
emailVARCHAR(255)Member email address
loans
ColumnTypeDescription
loan_idPKINTUnique loan identifier
member_idINTMember who holds the loan
loan_statusVARCHAR(20)Current loan status
scheduled_end_dateDATEScheduled date for the final loan payment
loan_payments
ColumnTypeDescription
payment_idPKINTUnique payment identifier
loan_idINTLoan associated with the payment
payment_dateDATEDate the payment was posted
payment_statusVARCHAR(20)Processing status of the payment
payment_amountDECIMAL(12,2)Payment amount
Tablesmembersloansloan_payments
Interviewer

Your question is Early Loan Payment Completion. 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.