How to calculate last period change percentage or same period last year change percentage?

influxdb

#1

hi, i’m new to Influx, i can not figure out a way to calculate something like last period change percentage and same period last year change percentage.

Suppose i’ve got the following data:

insert sale value=110 2018-10-01T00:00:00z
insert sale value=112 2018-11-01T00:00:00z
insert sale value=110 2019-12-01T00:00:00z

the last period is calculated by: (value_this_period - value_last_period) / value_last_period.

How to do with Influx or QL?

Thanks