sumArray
Description
The ForEach
combinator
can be applied to the sum
aggregate function to turn it from an aggregate
function which operates on row values to an aggregate function which operates on
array columns, applying the aggregate to each element in the array across rows.
Example Usage
For this example we'll make use of the hits
dataset available in our SQL playground.
The hits
table contains a column called isMobile
of type UInt8 which can be
0
for Desktop or 1
for mobile:
We'll use the sumForEach
aggregate combinator function to analyze how
desktop versus mobile traffic varies by hour of the day. Click the play button
below to run the query interactively: