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 7-Day Running Total by Store
00:00
5 left

SQL 7-Day Running Total by Store

MediumSQL · PostgreSQL

Problem

Business Context

Arby's Marketing Analytics uses store-level sales trends to evaluate campaign performance and promotional lift. A seven-day rolling total helps smooth daily variation while preserving store-level detail.

Task

Write a PostgreSQL query that returns each store's daily sales and its seven-day running sales total. Include dates with recorded sales, aggregate multiple transactions from the same store and date before applying the rolling calculation, and exclude transactions that do not match a known store.

Requirements

  1. Join sales_transactions to stores to return the store name.
  2. Calculate daily sales per store using SUM(sale_amount).
  3. Calculate a calendar-based seven-day total that includes the current date and the six preceding calendar days.
  4. Return results ordered by store ID and sales date.

Schema

stores
ColumnTypeDescription
store_idPKINTEGERUnique Arby's restaurant identifier
store_nameVARCHAR(100)Restaurant name
cityVARCHAR(80)Restaurant city
regionVARCHAR(40)Operating region
sales_transactions
ColumnTypeDescription
transaction_idPKINTEGERUnique transaction identifier
store_idINTEGERReferenced restaurant identifier
sale_dateDATEDate of the sale
sale_amountNUMERIC(10,2)Transaction sales amount
channelVARCHAR(20)Sales channel
Tablesstoressales_transactions
Interviewer

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