Querry to filter unwanted data from the database

In my project, the influxDB recieve same sensor data 3 times from three different sensor gateways with few seconds of defference in timestamp in order to maintain the availability . Becasue, if one sensor gateway fails, other two recieve data of the same sensor and save in the same database . This process happens every 6 minute.

But for the calculation purposes, I need only one data point out of those 3 points becasue it contains same sensor data. The differences of those 3 data points are the gateway name and few seconds of difference in timestamp.

Is there any influxQL function to do this task ?

Hello @malith,
I’m not sure how to do this with InfluxQL but you can do that with Flux. Do you have it enabled or are you willing to upgrade?
Basically you’d do a combination of conditional filtering with if exists

I can write the flux for you if you have access to it.