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

City Category Orders Profit
'London' 'Office Supplies' 8 120.10
'London' 'Furniture' 1 750.00
'Moscow' 'Furniture' 2 1250.50
'Moscow' 'Office Supplies' 4 85.34
'San Francisco' 'Office Supplies' 23 723.00
'Detroit' 'Furniture' 5 6205.87

Grouped by [City].

Sorted by [City].

Result

[City] SUM([Orders]) SUM([Profit])
'Detroit' 5 6205.87
'London' 9 870.10
'Moscow' 6 1335.84
'San Francisco' 23 723.00

Data source support

ClickHouse 19.13, Microsoft SQL Server 2017 (14.0), MySQL 5.6, PostgreSQL 9.3.

Previous
Next