Mode Function

Connectivity
Fan

Mode Function

I am searching for a Mode aggregate function.

the mode is the value that occurs the most frequently in a data set
3 REPLIES
Senior Apprentice

Re: Mode Function

Hi Siinis,

SELECT col
FROM tab
GROUP BY 1
QUALIFY
RANK() OVER (ORDER BY COUNT(*) DESC) = 1

Dieter
Fan

Re: Mode Function

Thank you very much. I had come up with something similar but yours is cleaner.

Re: Mode Function

Hi Dieter,

What if I need to find the MODE for multiple varaiables?

For example,

SELECT a, b, MODE(d), MODE(e), MODE(f)

From tbl

group by??

Thanks!

Carey