Re: percentile_cont from array?

Поиск
Список
Период
Сортировка
От Rui DeSousa
Тема Re: percentile_cont from array?
Дата
Msg-id 333B10FF-ADD4-432C-B3D2-7A48E9E5ADF6@crazybean.net
обсуждение исходный текст
Ответ на percentile_cont from array?  (Wells Oliver <wells.oliver@gmail.com>)
Список pgsql-admin


On Sep 11, 2023, at 4:01 PM, Wells Oliver <wells.oliver@gmail.com> wrote:

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?

I think it is a personal preference; does the function make the code more readable?  The CTE is not needed, nor is the function.

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


select percentile_cont(.9) within group (order by i asc)
from unnest(array[1,2,3,4,5]) i
;

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: btree/gist index on date and searching using BETWEEN or >= and <=
Следующее
От: Laurenz Albe
Дата:
Сообщение: Re: pg_stat_statements_info