Skip to main content

SUM (SQL)

A window function that assigns the sum of the values of the field column within the specified window frame to all rows in that window frame.

Synopsis

SUM(field)

Description

SUM adds up the value of the field column within the frame to all rows in that frame. SUM supports the ROWS clause.

This window function works analogously to the aggregate function SUM.

Arguments

field

A column that specifies the values to be summed up.

Examples

The following example calculates the total salary for each department:

SELECT SUM(Salary) OVER (PARTITION BY Department) FROM Company.Employee

See Also

FeedbackOpens in a new tab