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 SQL
00:00
5 left

Running Total SQL

EasySQL · PostgreSQL

Problem

The Tata Consultancy Services North America sales team tracks TCS BaNCS implementation revenue across client accounts. Write a PostgreSQL query that reports monthly North American sales and the cumulative sales total through each month.

Requirements

  1. Join sales transactions to client accounts and include only accounts in the North America region.
  2. Restrict transactions to January through April 2025 and aggregate sales by calendar month.
  3. Calculate a running total of monthly sales in chronological order using a window function.
  4. Return the month as YYYY-MM, monthly sales, and the running total, ordered from earliest to latest month.

Schema

tcs_client_accounts
ColumnTypeDescription
account_idPKINTEGERUnique client account identifier
account_nameVARCHAR(100)Client account name
regionVARCHAR(50)Client sales region
tcs_sales_transactions
ColumnTypeDescription
transaction_idPKINTEGERUnique sales transaction identifier
account_idINTEGERReferences tcs_client_accounts.account_id
sale_dateDATEDate of the sale
amountNUMERIC(12,2)Sales amount in USD
Tablestcs_client_accountstcs_sales_transactions
Interviewer

Your question is Running Total SQL. 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.