How to calculate Statistical Mode in Hive?
Lets say to find the mode for a column in hive table.
Do we have any inbuilt functions for computing Mode.
There is no mention of a mode function in the official docs (see Built-in Aggregate Functions).
But the query to get the mode of a column is pretty simple, so a native function might not be necessary.
select age from (
select age, count(age) as age_cnt
from mytable
group by age
order by age_cnt desc
limit 1
) t1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With