Re: [GENERAL] aggregate question

Поиск
Список
Период
Сортировка
От William D. McCoy
Тема Re: [GENERAL] aggregate question
Дата
Msg-id 199810221728.NAA01843@aeolus.geo.umass.edu
обсуждение исходный текст
Ответ на Re: [GENERAL] aggregate question  (Ulf Mehlig <umehlig@uni-bremen.de>)
Список pgsql-general
Ulf,  As a partial answer to your question about statistical functions
and std. deviation in particular, I have pulled out an example query
that I have used in the past as an example:


select lab_no, prep_no, avg(hai), max(hai), min(hai),
|/((sum(hai^2)-(count(hai)::float8)*(avg(hai)^2))/count(hai)::float8)
    as stdhai, count(hai), peak_values
from hyd_ratios
group by peak_values, lab_no, prep_no;


The expression on the second line of the query returns the standard
deviation of my data "hai" (which is float8) in this case.  Note that
count returns an integer that must be cast as float8.  One could
retrieve the variance in a similar way.  These are awkward to type,
but I usually keep queries in text files that I send to psql on a
command line.  Of course, a nice set of statistical functions would be
welcome.

--
William D. McCoy
Geosciences
University of Massachusetts
Amherst, MA  01003

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

Предыдущее
От: "Michael A. Koerber"
Дата:
Сообщение: Bug in pg_dump/pg_dumpall handling of CONSTRAINTS?
Следующее
От: "Mark D. Butler"
Дата:
Сообщение: Postgres SQL Web Page