First page Back Continue Last page Image

A Window with a Frame using ROWS

SELECT vendor_id, invoice_date, invoice_total,

SUM(invoice_total) OVER(PARTITION BY vendor_id

ORDER BY invoice_date

ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)

AS vendor_total

FROM invoices

WHERE invoice_date

BETWEEN '2018-04-01' AND '2018-04-30'

The Target data here is vendor_id by invoice_date so we can see a accumulated total by vendor_id per invoice_date filling the vendor_total column