About this tutorial
Calculate P&L only for the reporting period
This tutorial builds a single Oracle SQL query that calculates Repo P&L for the portion of each transaction that actually overlaps with the reporting period.
The key step is defining the calculation boundaries with GREATEST and LEAST. This lets the same query handle transactions that started before the period, mature during the period, or remain open on the report date.