Re: user defined aggregate for percentile calculations

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Re: user defined aggregate for percentile calculations
Дата
Msg-id 20090406085328.GA8320@a-kretschmer.de
обсуждение исходный текст
Ответ на user defined aggregate for percentile calculations  (Kashmir <kashmir_us_1999@yahoo.com>)
Ответы Re: user defined aggregate for percentile calculations  (Kashmir <kashmir_us_1999@yahoo.com>)
Список pgsql-general
In response to Kashmir :
>
> cant seem to find anything about this,
> would it possible at all to create a percentile-aggregate in pgres?
> any pointers?
> tia
> -k

I'm not sure if i understand your problem, but how about:

test=*# select * from percentile ;
 id | value
----+-------
  1 |    10
  2 |    20
  3 |    30
  4 |    50
(4 rows)

test=*# select a.id, a.value, (a.value*100/foo.summe)::numeric(10,2)
from percentile a, (select sum(value) as summe from percentile ) as foo
group by a.id, a.value, foo.summe order by id;
 id | value | numeric
----+-------+---------
  1 |    10 |    9.00
  2 |    20 |   18.00
  3 |    30 |   27.00
  4 |    50 |   45.00
(4 rows)


HTH, Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

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

Предыдущее
От: "Albe Laurenz"
Дата:
Сообщение: Re: Postgres Security Checklist
Следующее
От: Abdul Rehman
Дата:
Сообщение: Number Conversion Function