0
← Exercises/
Window Functions•3 of 14
Window FunctionsAdvanced

Cumulative Cashflow Running Total

Scenario

Treasury and cash management require real-time visibility into the rolling liquidity trajectory as daily transactions settle.

Task
Given daily bank cash inflows and outflows in `cashflow_ledger`, compute the day's net balance and the cumulative running bank balance. Calculate: 1. `entry_date` 2. `daily_net`: (`inflow_amount - outflow_amount`) 3. `running_balance`: Cumulative sum of `daily_net` from the first entry up to the current row Order by `entry_date` ascending.
Expected Output Format

Time-series showing entry_date, daily_net, and running_balance.

Input Tables & Sample Data0 tables
Loading database schema...
Need a hint?
query.sql|Local Sandbox
Loading SQL editor...
Click "Run" or press ⌘ + Enter to execute your query

About the “Cumulative Cashflow Running Total” SQL Problem

Business Scenario

Treasury and cash management require real-time visibility into the rolling liquidity trajectory as daily transactions settle.

Expected Output & Criteria

Time-series showing entry_date, daily_net, and running_balance.

Database Table Schema (PostgreSQL DDL)

PostgreSQL 16 WASM

This challenge executes directly against the following relational schema in your browser:

CREATE TABLE cashflow_ledger (
        entry_id INT PRIMARY KEY,
        entry_date DATE NOT NULL,
        inflow_amount NUMERIC(12, 2) NOT NULL DEFAULT 0.00,
        outflow_amount NUMERIC(12, 2) NOT NULL DEFAULT 0.00
      );

Target SQL Clauses & Operators

SUMOVERORDER BY

Want more Window Functions practice?

Explore the full syllabus of 14 exercises, syntax guides, and interview pitfalls.

View Window Functions Track→