Maximum value from two different queries

I’ve created two queries from network traffic In and Out:

How to create one line and output only one max value from from two lines.
I mean something like if In > Out place In value or In < Out place Out value.

You can achieve this by using the max() function along with the union operator to merge the results of the two queries and then select the maximum value from the combined dataset. Here’s an example of how you can do it:

SELECT max(value) FROM (
SELECT max(column_name) AS value FROM table1 WHERE time > now() - 1h
SELECT max(column_name) AS value FROM table2 WHERE time > now() - 1h


You can also do this with a transformation:

as @robertonorton said however, it’s probably better for performance to let the query do the work, instead of making grafana do it


Thanks for replies.
Maybe perfomance with query is mo’ better, but look like InfluxDB doesn’t have UNION operation so I done this via trasformation. :grinning:

the way you’ve shown it’s not bad either, I think, but I still stand by my answer :3