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 with Window Functions
00:00
5 left

SQL with Window Functions

MediumSQL · PostgreSQL

Problem

Describe a time you used SQL window functions to transform Robinhood-style data for analysis.

For this hands-on version, write a SQL query that summarizes eligible trades by user and calendar month, then ranks users within each account type and month. Ignore trades whose status is not FILLED or whose price is NULL.

Output

  1. One row per user with eligible activity in a month.
  2. Columns: account_type, trade_month, user_id, username, trades_count, monthly_traded_value, and monthly_rank.
  3. Sort by account type, month, rank, and user ID.

Schema

users
ColumnTypeDescription
user_idPKINTUnique user identifier
usernameVARCHAR(100)User display name
account_typeVARCHAR(30)Robinhood-style account classification
trades
ColumnTypeDescription
trade_idPKINTUnique trade identifier
user_idINTUser who placed the trade
traded_atTIMESTAMPTimestamp when the trade was recorded
symbolVARCHAR(20)Security ticker symbol
sideVARCHAR(20)Trade direction or transaction side
quantityNUMERIC(14,2)Number of shares or units
priceNUMERIC(14,2)Execution price per unit
statusVARCHAR(20)Trade processing status
Tablesuserstrades
Interviewer

Your question is SQL with Window Functions. Start with the requirements and the two 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.