Get higher value between two fields

Hi All,
I’m using InfluxDB 1.7 and I have a use case where I need to extract the higher value of two fields.

e.g. These two queries will give highest RX and TX for the specified time interval. Visualisation is a table.

Query1: SELECT top(“ifOutBits_rate”, “ifName”, 20) FROM “ports”
Query2: SELECT top(“ifInBits_rate”, “ifName”, 20) FROM “ports”

Is there a way to filter this further and get only the higher of the two queries in the table? 4.90 Gbps for Ethernet1/1 and 4.94 Gbps for Ethernet 1/2 in the example. I’m basically trying to get highest interface utilization rate rx or tx

Thanks.

1 Like

Hello @kenmaina,
Welcome! I’m still looking into how to do that with InfluxQL/I’m not entirely sure it’s possible. However, you can easily do that with flux with the top() function. With it you can do something like:

top(n:20, columns: ["_value"])

one you’ve filtered for a table that has both of your desired fields. You can enable flux on v1.7+.