Re: No stddev() for interval?

Поиск
Список
Период
Сортировка
От Brendan Jurd
Тема Re: No stddev() for interval?
Дата
Msg-id 37ed240d0605201055h59f08267h9706cf8475eab82d@mail.gmail.com
обсуждение исходный текст
Ответ на No stddev() for interval?  ("Brendan Jurd" <direvus@gmail.com>)
Список pgsql-general

If the intervals are all expressed in seconds then sure, the calculation
is straightforward and useful.  I'm wondering what happens when nonzero
values of days and months get in there.

                        regards, tom lane


The existing logic used in avg(interval) can be seen in backend/utils/adt/timestamp.c, refer to functions interval_accum, interval_avg and interval_div.

interval_div(interval, double) is the most interesting for this discussion.  There is a helpful comment that reads /* evaluate fractional months as 30 days */.

So for example, interval_div('4 mons'::interval, 3) gives you '1 mon 10 days'.

It's not perfect, but doing arithmetic that involves converting between months and days never is.  All in favour of deleting the month as unit of measurement of time say "aye".

Well that's not going to happen in my lifetime.  How about we just extend this same logic over to stddev and variance?  It's strange having avg but not the other two.

Regards,
BJ

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: No stddev() for interval?
Следующее
От: "Dawid Kuroczko"
Дата:
Сообщение: Let's make CPgAN!