SUM

Function SUM is also found in the following categories: Window functions.

Syntax

SUM( value )
SUM( value     [ FIXED ... | INCLUDE ... | EXCLUDE ... ]     [ BEFORE FILTER BY ... ]   )

More info:

Description

Returns the sum of all expression values. Applicable to numeric data types only.

Argument types:

  • valueFractional number | Integer

Return type: Same type as (value)

Example

Source data

CityCategoryOrdersProfit
'London''Office Supplies'8120.10
'London''Furniture'1750.00
'Moscow''Furniture'21250.50
'Moscow''Office Supplies'485.34
'San Francisco''Office Supplies'23723.00
'Detroit''Furniture'56205.87

Grouped by [City].

Sorted by [City].

Result

[City]SUM([Orders])SUM([Profit])
'Detroit'56205.87
'London'9870.10
'Moscow'61335.84
'San Francisco'23723.00

Data source support

ClickHouse 21.8, Microsoft SQL Server 2017 (14.0), MySQL 5.7, Oracle Database 12c (12.1), PostgreSQL 9.3, YDB.

Previous
Next