From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Nick Dro <postgresql(at)walla(dot)co(dot)il> |
Cc: | hubert depesz lubaczewski <depesz(at)depesz(dot)com>, "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Re: PostgreSQL needs percentage function |
Date: | 2017-12-18 16:19:08 |
Message-ID: | CAFj8pRBac4vEH2eR1qZPr0ZAMbnW7yWw9k3pLomTZSnnC+mmsg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
2017-12-18 17:13 GMT+01:00 Nick Dro <postgresql(at)walla(dot)co(dot)il>:
>
> Hi,
> I know how to implement this. It's not the issue.
> It's very easy to implement absolute value as well yet still PostgreSQL
> gives abs(x) function which is build in function.
> My claim is that if there is a build in function for absolute value why
> not for percentage? Both are very basic mathematical operations.
>
> Can you give a good reason why absolute value has a build in function
> while percentage is not?
>
probably history
abs is some basic functions - the implementation is not primitive. Percent
function is maybe in spreadsheets, but I don't remember this function from
any classic language - more it can be simply implemented by numeric
operators.
In this case, I am not a fan of this functions, you can write just 25 *
0.20
Regards
Pavel
>
> ב דצמ׳ 18, 2017 17:44, hubert depesz lubaczewski כתב:
>
> On Mon, Dec 18, 2017 at 02:23:38PM +0200, Nick Dro wrote:
> > Hi,
> > Why PostgreSQL doesn't have build-in function to calculate percentage?
> > somthing like percent(number,%
> > for example:
> > select percent(100,1) will calculate 1% of 100 = 1
> > select percent(25,20) will calculate 20% of 25 = 5
> What is the problem with using normal multiplication for this?
> depesz
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2017-12-18 16:21:49 | Re: Re: PostgreSQL needs percentage function |
Previous Message | Geoff Winkless | 2017-12-18 16:17:45 | Re: Re: PostgreSQL needs percentage function |