RE: Re: PostgreSQL needs percentage function

From: Nick Dro <postgresql(at)walla(dot)co(dot)il>
To: htfoot(at)gmail(dot)com, pgsql-general(at)postgresql(dot)org
Cc: pgsql-general(at)postgresql(dot)org <pgsql-general(at)postgresql(dot)org>
Subject: RE: Re: PostgreSQL needs percentage function
Date: 2017-12-19 09:13:23
Message-ID: ^23F28E7347914F7AC39333AE5BF63A6746BFD91F@walla.co.il
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

<div dir='rtl'><div>
<div dir="rtl">
<div dir="ltr">This is exactly why I think there should be some build-in function for that...</div>
<div dir="ltr">Percentage calculation exists in almost any databse and information system - it requires from use to implement many functions on thier own for something that is very basic.</div>
<div dir="ltr">The general idea of my request is that postgresql should have build in function for percentage calculation it doesn't have to me the exact example I gave. Any thing will be better than none.</div>
<div dir="ltr">&nbsp;</div>
<div dir="ltr">&nbsp;</div>
</div>
<section class="cust_msg_end"></section>
<blockquote style="margin: 0; margin-bottom: 20px; border-top: 1px solid #e0e0e0;"><br />ב דצמ׳ 18, 2017 18:28, Michael Nolan כתב:
<blockquote style="margin: 0; margin-bottom: 20px; border-top: 1px solid #e0e0e0;">
<div dir="ltr"><br />
<div><br />
<div>On Mon, Dec 18, 2017 at 6:23 AM, Nick Dro <span dir="ltr">&lt;<a href="mailto:postgresql(at)walla(dot)co(dot)il" target="_blank" rel="noopener">postgresql(at)walla(dot)co(dot)il </a>&gt;</span> wrote:<br />
<blockquote style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;">
<div dir="rtl">
<div dir="ltr">Hi,</div>
<div dir="ltr">Why PostgreSQL doesn't have build-in function to calculate percentage? somthing like percent(number,%</div>
<div dir="ltr">for example:</div>
<div dir="ltr">select percent(100,1) will calculate 1% of 100 = 1</div>
<div dir="ltr">select percent(25,20) will calculate 20% of 25 = 5</div>
<div dir="ltr">&nbsp;</div>
<div dir="ltr">Seems like a nice addition to the math functions list:</div>
<div dir="ltr"><a href="https://www.postgresql.org/docs/9.5/static/functions-math.html" target="_blank" rel="noopener">https://www.postgresql.org/<wbr />docs/9.5/static/functions-<wbr />math.html</a></div>
<div dir="ltr">&nbsp;</div>
<div dir="ltr">This is veryhelpull function, many uses percentage calculation in thier work and it will simplify the process. Percentage calculation is considered a basic math operation and I think postgresql should support it as a build-in function.</div>
<div dir="ltr">Seems like easy to implment isn't it?</div>
</div>
</blockquote>
</div>
</div>
<div>&nbsp;</div>
<div>It's a bit trickier than that, because you';ll have to deal with integers, real, double precision, etc.&nbsp; You may also want to deal with null values.&nbsp; I found it more useful to write a function that displays X as a percentage of Y, rounded to 1 digit to the right of the decimal point.</div>
<div>--</div>
<div>Mike Nolan</div>
</div>
</blockquote>
</blockquote>
</div></div>

Attachment Content-Type Size
unknown_filename text/html 2.6 KB

Responses

Browse pgsql-general by date

  From Date Subject
Next Message gregoryrevilla 2017-12-19 09:53:50 Re: Character set display
Previous Message Rob Nikander 2017-12-19 03:55:06 Re: reclaiming space from heavily used tables?