<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"> </div>
<div dir="ltr"> </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"><<a href="mailto:postgresql(at)walla(dot)co(dot)il" target="_blank" rel="noopener">postgresql(at)walla(dot)co(dot)il </a>></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"> </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"> </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> </div>
<div>It's a bit trickier than that, because you';ll have to deal with integers, real, double precision, etc. You may also want to deal with null values. 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>