Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 860 Bytes

File metadata and controls

29 lines (22 loc) · 860 Bytes
description
Returns the sum of non-NULL input expressions.

SUM

Syntax

SUM(column_name number or interval) → same as input

  • column_name: The column containing the values to sum.

Examples

SELECT SUM(base_fee_per_gas) 
FROM eth.recent_blocks
-- 9.858134477692287E8

{% code title="Window function example" %}

SELECT "base_fee_per_gas", "gas_used", SUM("total_gas_used") 
OVER (partition by "base_fee_per_gas") as "sum_gas_used" 
FROM eth.recent_blocks 
LIMIT 1
-- base_fee_per_gas, gas_used, sum_gas_used
-- -51.0, -4.0, -56.0

{% endcode %}