Re: PostgreSQL needs percentage function

From: Edson Carlos Ericksson Richter <richter(at)simkorp(dot)com(dot)br>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: PostgreSQL needs percentage function
Date: 2017-12-18 17:08:14
Message-ID: a9885982-0939-c0c6-badc-32228b4874c3@simkorp.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Em 18/12/2017 15:01, David G. Johnston escreveu:
> On Mon, Dec 18, 2017 at 9:56 AM, Edson Carlos Ericksson Richter
> <richter(at)simkorp(dot)com(dot)br <mailto:richter(at)simkorp(dot)com(dot)br>>wrote:
>
> But, is it possible to have a aggregate function that calculates
> de percent from the sum (and/or count) total (as a value from 0
> ... 1) for numeric (or double)?
>
>
> ​Do you mean:
>
> SELECT id, val, val / (sum(val) OVER ())
> FROM vals;​
>
> ​David J.​
>

I've never thought about Window Functions that way.
Thanks, it is enligthning.

:-)

Regards,

Edson.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rob Nikander 2017-12-18 19:03:14 reclaiming space from heavily used tables?
Previous Message Corey Taylor 2017-12-18 17:07:40 Re: PostgreSQL needs percentage function