Skip to main content
Version: 24.3.x

Categories: Aggregate, Window

SUM

Returns the sum of non-NULL input expressions.

Syntax

SUM(column_name number or interval) → same as input

  • column_name: The column containing the values to sum.

Examples

Aggregate function example
SELECT SUM(trip_distance_mi) FROM Samples."samples.dremio.com"."NYC-taxi-trips"
-- 9.858134477692287E8
Window function example
SELECT "tip_amount", "fare_amount", SUM("total_amount") OVER (partition by "tip_amount") as "sum_amount" FROM Samples."samples.dremio.com"."NYC-taxi-trips" LIMIT 1
-- tip_amount, fare_amount, sum_amount
-- -51.0, -4.0, -56.0