Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Case Study and SQL for Operational Data

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Case Study and SQL for Operational Data. Start with the requirements and the four tables on the right.

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.

Problem

Case study based and also sql based

Using the provided tables, identify accounts whose net contributions increased strictly from January through March 2025. Return only accounts that rank among the top two qualifying accounts within their investor segment.

Output

  1. One row per qualifying account with account_id, investor_name, segment, january_net, february_net, march_net, funds_used, and segment_rank.
  2. Include only accounts with all three monthly values and a segment rank of 2 or better.
  3. Sort by segment, descending march_net, then account_id.

Schema

investors
ColumnTypeDescription
investor_idPKINTInvestor identifier
investor_nameVARCHAR(100)Investor name
segmentVARCHAR(50)Investor segment
accounts
ColumnTypeDescription
account_idPKINTAccount identifier
investor_idINTReferenced investor
account_typeVARCHAR(40)Account type
opened_dateDATEAccount opening date
funds
ColumnTypeDescription
fund_idPKINTFund identifier
fund_nameVARCHAR(100)Fund name
asset_classVARCHAR(40)Fund asset class
transactions
ColumnTypeDescription
transaction_idPKINTTransaction identifier
account_idINTReferenced account
fund_idINTReferenced fund
transaction_dateDATETransaction date
transaction_typeVARCHAR(30)Contribution or withdrawal
amountDECIMAL(12,2)Unsigned transaction amount
Tablesinvestorsaccountsfundstransactions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results