InfluxQL, Subquery Problem

Hi, I need some help to understand the behavior of some queries. I’m using Influxdb 1.8.4

For example, I want to get the last 5 records
> select * from smedicion order by time desc limit 5
name: smedicion
time Equipo Guardado Vel iso14 iso4 iso6 sensor
---- ------ -------- — ----- ---- ---- ------
1612529113033000000 2 05-02-2021 12:45:13 33 0 0 0 s16
1612446093452000000 2 04-02-2021 13:41:33 33 10 3 2 s16
1612446091845000000 2 04-02-2021 13:41:31 33 10 3 2 s16
1612446089717000000 2 04-02-2021 13:41:29 33 11 3 2 s16
1612446087740000000 2 04-02-2021 13:41:27 33 10 3 2 s16

Now, the maximum value (ISO14) of those 5 records ( = 11). And I am not getting a correct value
> select max(iso14) from (select iso14 from smedicion order by time desc limit 5) order by time desc
name: smedicion
time max
---- —
1609106044851000000 5

But if I do it with TOP(value,1), I get the expected value

> select top(iso14,1) from (select iso14 from smedicion order by time desc limit 5) order by time desc
name: smedicion
time                top
----                ---
1612446089717000000 11

So what am I doing wrong?

I get the same problem, when using other functions like MIN and SUM. Also in other tables the query if it works

On Github I found a report of the same problem, with a better explanation

https://github.com/influxdata/influxdb/issues/20056