How to use druid for difference calculation and convert COUNTER to GAUGE

I have some Counter Type data in druid, I want to calculate the difference between these data between two adjacent timestamps, just like using difference syntax in influxdb:

SELECT DIFFERENCE(SUM(“FIELD_NAME”)) FROM “XXX”

Is this possible in druid?

Yes, it is possible to do comparison in Druid, but probably you do not want to write a Druid query for each difference?

One thing to consider is probably use Imply’s Pivot for its comparison feature, which could generate the queries automatically and present the output in diagrams or tables.

https://docs.imply.io/on-prem/visualize/time-compare