Oracle SUM Function: Usage Guide
The SUM function is one of the aggregate functions in Oracle database, used to calculate the total sum of a specified column.
Syntax: Sum of column
Specifications:
- Column: the name or expression of the column to calculate the total sum.
Return value: the calculated total sum.
Important points to note:
- The SUM function can only be used with columns that are numerical in type.
- The SUM function will ignore any NULL values in the column when calculating.
- To calculate the total sum of multiple columns, you can use multiple SUM functions to calculate the sum of each column separately.
Assume there is a table called “orders” with columns “order_id” and “amount”, we can use the SUM function to calculate the total sum of the “amount” column.
SELECT SUM(amount)
FROM orders;
This will return the sum of all values in the “amount” column.