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
Window Functions for Trader Ranking
00:00
5 left

Window Functions for Trader Ranking

MediumSQL · PostgreSQL

Problem

Write a complex SQL query utilizing window functions to rank transaction volumes per trader over a monthly period.

Use the provided trader, transaction, and trading venue tables. Include executed transactions from January through March 2025, excluding non-positive quantities, inactive venues, unmatched traders, and transactions without a venue.

Output

  1. One row per trader and month, with month_start, trader_id, trader_name, total_volume, transaction_count, total_notional, volume_rank, previous_month_volume, and volume_share_pct.
  2. Rank ties equally by descending total volume. Use NULL when a trader has no prior month.
  3. Order by month, rank, and trader ID.

Schema

traders
ColumnTypeDescription
trader_idPKINTUnique trader identifier
trader_nameVARCHAR(100)Trader display name
desk_nameVARCHAR(100)Trading desk assigned to the trader
transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction identifier
trader_idINTTrader who executed the transaction
venue_idINTExecution venue
executed_atTIMESTAMPTransaction execution timestamp
quantityINTNumber of units traded
priceNUMERIC(12,2)Execution price per unit
statusVARCHAR(20)Transaction lifecycle status
trading_venues
ColumnTypeDescription
venue_idPKINTUnique venue identifier
venue_codeVARCHAR(30)Venue code
is_activeBOOLEANWhether the venue is active for reporting
Tablestraderstransactionstrading_venues
Interviewer

Your question is Window Functions for Trader Ranking. 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.