Re: stddev returns 0 when there is one row

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: stddev returns 0 when there is one row
Дата
Msg-id 18667.1050974816@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: stddev returns 0 when there is one row  (nolan@celery.tssi.com)
Список pgsql-general
nolan@celery.tssi.com writes:
> wouldn't the easiest way to offer both sample and population formulas for
> variance and standard deviation be to just add two new functions,
> varp and stddevp, most of the code for which already exists?

As Joe pointed out, SQL200x seems to have laid down the law already on
what to call these things.

> That way they remain single-input aggregates.

My comment about multiple inputs was in response to the suggestion of
grouped input, which I took to mean that you'd want to write something
like "SELECT STDDEV_GROUPED(value, num_occurrences) FROM foo".

You could hack your way around the problem by defining the aggregate
to take a two-element array type:
    SELECT STDDEV_GROUPED(ARRAY[value, num_occurrences]) FROM foo
but this seems ugly and inefficient.

            regards, tom lane


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

Предыдущее
От: Joe Conway
Дата:
Сообщение: Re: Documentation
Следующее
От: Tom Lane
Дата:
Сообщение: Re: postgresql doesn't start