# Selecting the maximum from an entire range for every timestamp

Hello! I am attempting to draw a straight line in Grafana like in rrd (in this case the maximum, not 95th percentile):

I have the following query

``````SELECT non_negative_derivative("bytes-sent", 1s) *8 AS bps FROM "interface/latest/generic-counters" WHERE "interface-name" = 'Bundle-Ether20') AND time >= now() - 24h

time                     bps
----                     ---
2019-07-31T04:50:40.612Z 4186760242.165622
2019-07-31T04:51:10.614Z 4182186443.037131
2019-07-31T04:51:40.616Z 4324680719.9520035
[etc]

``````

I am able to calculate the maximum over the entire range using a sub-query:

``````SELECT MAX("bps") FROM (SELECT non_negative_derivative("bytes-sent", 1s) *8 AS bps FROM "interface/latest/generic-counters" WHERE "interface-name" = 'Bundle-Ether20') AND time >= now() - 24h)

time                     max
----                     ---
2019-07-31T11:03:11.453Z 10753011808
``````

In order to get Grafana to draw the line I believe I need a result that has the same maximum value on each timestamp. Is this possible?

``````time                     bps			max
----                     ---			---
2019-07-31T04:50:40.612Z 4186760242.165622	10753011808
2019-07-31T04:51:10.614Z 4182186443.037131 	10753011808
2019-07-31T04:51:40.616Z 4324680719.9520035	10753011808
[etc]
``````

Hi @bpbp-boop welcome to the community ,

it is indeed possible to have the same maximum value on each timestamp ,

best regards

Thanks for the welcome
Is it possible to combine the two queries to get the result I am after? The maximum is dependent on the time range being looked at so I can’t write it into every point.

Maybe not. It would be nice if Grafana supported dynamic threshold lines for this purpose. Does anyone know any good Grafana alternatives?

did you figure this out? – interesting question