Returns the total of the values.
sum([all | distinct] expression)
select avg(advance), sum(total_sales) from titles where type = "business"
select type, avg(advance), sum(total_sales) from titles group by type
select pub_id, sum(advance), avg(price) from titles group by pub_id having sum(advance) > $25000 and avg(price) > $15
sum, an aggregate function, finds the sum of all the values in a column. sum can only be used on numeric (integer, floating point, or money) datatypes. Null values are ignored in calculating sums.
When you sum integer data, the SAP ASE server treats the result as an int value, even if the datatype of the column is smallint or tinyint.When you sum bigint data, the SAP ASE server treats the result as a bigint.To avoid overflow errors in DB-Library programs, declare all variables for results of averages or sums appropriately.
You cannot use sum with the binary datatypes.
This function defines only numeric types; use with Unicode expressions generates an error.
compute clause, group by and having clauses, select, where clause in Reference Manual: Commands
Transact-SQL Users Guide
ANSI SQL – Compliance level: Transact-SQL extension.
Any user can execute sum.