logo

Oracle NextGen

score

SQL Challenge

Challenge #15 – Running Total with Reset

Challenge Overview
Calculate a running total of daily sales for each product category, but reset the total when it exceeds $1000.

Requirements

  • Return columns: sale_date, category, daily_amount, running_total.
  • Calculate running total within each category ordered by date.
  • Reset the running total to the current day's amount when it would exceed 1000.
  • Order by category and sale_date.
Sample Dataset
Preview the schema and seeded rows you can query against.

daily_sales

Daily sales by category.

Columns
NameTypeNotes
sale_idINTPrimary key
sale_dateDATESale date
categoryVARCHARProduct category
daily_amountDECIMALDay's total
Sample Rows
sale_idsale_datecategorydaily_amount
12024-01-01Electronics300
22024-01-02Electronics400
32024-01-03Electronics500
42024-01-04Electronics200
52024-01-01Furniture600
62024-01-02Furniture300
72024-01-03Furniture400
SQL Playground
Loading editor…

Result Preview

Awaiting Run

Run your query to see the dataset preview.