Compare current value with one from past

Hi,

I have a sensor that sends eversy 0,5 seconds data to the influx DB. What I would like to obtain is the difference between the last sensor value and the sensor value from 5 mins ago.

sensor_value (t_Now) - sensor_value(t_Now-5m). Ist there a way to compute this difference directly from influx?