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
Running Total Sales by Date
00:00
5 left

Running Total Sales by Date

MediumSQL · PostgreSQL

Problem

Arcesium QA needs to validate cumulative sales balances shown for active portfolios. Sales can have multiple posted records on the same settlement date, including corrections and null amounts.

Write a PostgreSQL query that calculates a running total of posted sales by settlement date for each active portfolio.

Requirements

  1. Join portfolio_sales to portfolios and include only portfolios with portfolio_status = 'active'.
  2. Include only sales with sale_status = 'posted'.
  3. Aggregate sales to one row per portfolio and settlement date, treating a date containing only null amounts as zero.
  4. Calculate the cumulative sales total per portfolio in chronological order.

Schema

portfolios
ColumnTypeDescription
portfolio_idPKINTUnique portfolio identifier.
portfolio_nameVARCHAR(100)Human-readable Arcesium portfolio name.
portfolio_statusVARCHAR(20)Current portfolio lifecycle status.
portfolio_sales
ColumnTypeDescription
sale_idPKINTUnique sales record identifier.
portfolio_idINTPortfolio associated with the sale.
settlement_dateDATEDate on which the sale settled.
sale_amountDECIMAL(14,2)Signed monetary amount of the sale.
sale_statusVARCHAR(20)Processing status of the sale record.
Tablesportfoliosportfolio_sales
Interviewer

Your question is Running Total Sales by Date. 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.