InfluxDB queries - Cumulative sum of /

I’m trying to display the % difference of a stock on grafana.
Here’s the queries that return the daily % variation.

Values are parsed from a csv file by telegraf:

SELECT (close / open) - 1 AS "calculated_percentage" FROM "stock" WHERE $timeFilter tz('America/New_York')

This query is working for the daily % variation between open and close.
I would like to be able to aggregate with cumulative_sum to know the total variation between 2 selected date.

When I try to add cumulative_sum around the (close / open) that didn’t work.

Any idea?


Hello @xk3tchuPx,
you need to perform a nested subquery

something like
SELECT cumulative_sum("calculated_percentage") AS "cumul_sum" FROM (SELECT (close/open)....)```