10 lines
298 B
Text
10 lines
298 B
Text
# lst should be a DuckDB list
|
|
create or replace function mode(lst) as (
|
|
with cte as (
|
|
SELECT number, COUNT(*) as frequency
|
|
FROM (SELECT unnest(lst) as number)
|
|
GROUP BY number
|
|
ORDER BY frequency DESC
|
|
LIMIT 1)
|
|
(select number from cte) -- signal that the result is scalar
|
|
);
|