How to get the most frequent record in influxdb

I found a similar topic in Multiple count and where in query

but it just has three value 0,1,3, so that can use tag with “group by” operation.
but in my case,the value will be millions,so it can not use tags .

thanks