-
-
Notifications
You must be signed in to change notification settings - Fork 24
Window Functions
Mark Carrington edited this page Feb 15, 2025
·
1 revision
The OVER
clause can be used with the aggregate and ranking functions to include information about the group of records alongside each individual row.
SQL 4 CDS aims to support all the options within the OVER
clause except:
RANGE
UNBOUNDED FOLLOWING
Generate a running total using the SUM
function with an OVER
clause that includes all the rows up to the current row:
SELECT name,
revenue,
SUM(revenue) OVER (ORDER BY name ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS cumulative_revenue
FROM account
ORDER BY name