Hi,

I am new to InfluxDB. Using influx 2.0.

Usually, I work with SQL.

I am working with Grafana and I am trying to show on a graph the value of max() minus the min() value for the past 24h on a certain field.

For example, I have a service called “WhoIs” and I would like to see for the past 24h what was the maximum value of the measurement and substruct from it the minimum value from the past 24h.

So basically I am expecting to see in Grafana a number every time there is a change for example:

If the maximum value for the past 24hour is 200 and the current minimum is 180 then I would like to see on the graph a dot on the current time which states 20 (200-180).

I searched the community for an answer and saw one that maybe could fit, but it shows on the graph all the values the minimum and maximum, and not the sum of subtracting minimum from the maximum.

This what was suggested:

```
data = from(bucket: "my-bucket")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "cpu")
|> filter(fn: (r) => r["_field"] == "usage_system")
|> filter(fn: (r) => r["cpu"] == "cpu-total")
min = data
|> min()
max = data
|> max()
join(tables: {min: min, max: max}, on: ["_start", "_field", "_start", "host", "_measurement"], method: "inner")
|> map(fn: (r) => ({ r with _value: r._value_max - r._value_min }))
```

Also, what is the equivalent of SQLs “group by” function in Flux?

Any suggestion will be much appreciated.