| От | Martijn van Oosterhout |
|---|---|
| Тема | Re: how do you write aggregate function |
| Дата | |
| Msg-id | 20080310074638.GA12727@svana.org обсуждение исходный текст |
| Ответ на | Re: how do you write aggregate function (Justin <justin@emproshunts.com>) |
| Ответы |
Re: how do you write aggregate function
|
| Список | pgsql-general |
On Sun, Mar 09, 2008 at 11:40:47AM -0500, Justin wrote: > I got the aggregate function for weighted average done. I finely left > alone for more than 10 minutes to actual get it written. It takes 2 > value input Weight and the Value. it will sum the weighted entries to > create the constant then does the normal formula, but does not > percentage number but averaged number. A simple change on the return > line it can do percentages. If you're looking for performance, ISTM the best option would be to simply accumulate the weights and value*weight as you go and do a division at the end. That seems likely to beat any implementation involving array_append. Have a nice day, -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > Please line up in a tree and maintain the heap invariant while > boarding. Thank you for flying nlogn airlines.
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера