percentile_cont from array?

Поиск
Список
Период
Сортировка
От Wells Oliver
Тема percentile_cont from array?
Дата
Msg-id CAOC+FBVRp5J4=tCfbGRW3spHvtxJijKzU37wx_0Zofj9PTH3=Q@mail.gmail.com
обсуждение исходный текст
Ответы Re: percentile_cont from array?
Список pgsql-admin
I find myself needing to get percentile_cont values from array types and thus did this, wondering if anyone has any "you idiot that's available out of the box here" kind of feedback?

create or replace function public.percentile_array(numeric, numeric[])
    returns real
    language 'sql'
    immutable
as $$
    with u as (
        select unnest($2) as i
    )
    select percentile_cont($1) within group (order by i asc) from u;
$$;

alter function public.percentile_array owner to postgres;

select public.percentile_array(0.9, array[1,2,3,4,5]); -- 4.6


--

В списке pgsql-admin по дате отправления:

Предыдущее
От: Nikhil Ingale
Дата:
Сообщение: replorigin_checkpoint
Следующее
От: Wells Oliver
Дата:
Сообщение: pg_stat_statements_info