RE: Re: Re: PostgreSQL needs percentage function

From: Nick Dro <postgresql(at)walla(dot)co(dot)il>
To: melvin6925(at)gmail(dot)com, pavel(dot)stehule(at)gmail(dot)com, htfoot(at)gmail(dot)com, pgsql-general(at)postgresql(dot)org
Cc: Michael Nolan <htfoot(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org >> PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: RE: Re: Re: PostgreSQL needs percentage function
Date: 2017-12-20 16:32:10
Message-ID: ^627CC100C6F641996FB6344CF751C954AA0471E2@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">&nbsp;I said: "Percentage calculation exists in almost any databse and information system"<br /><br /></div>
<div dir="ltr">I didn't say it exists in any <span class="st">RDB</span>. I meant that any system that is using databse like information system uses percentace calculation therefor if most of the users of the databse need such function it make sence to have it in it's base code - ready for use rather than ask each one to implment his own.</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 />ב דצמ׳ 19, 2017 17:51, Melvin Davidson כתב:
<blockquote style="margin: 0; margin-bottom: 20px; border-top: 1px solid #e0e0e0;">
<div dir="ltr"><br />
<div><br />
<div>On Tue, Dec 19, 2017 at 4:54 AM, Pavel Stehule <span dir="ltr">&lt;<a href="mailto:pavel(dot)stehule(at)gmail(dot)com" target="_blank" rel="noopener">pavel(dot)stehule(at)gmail(dot)com </a>&gt;</span> wrote:<br />
<blockquote style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid #cccccc; padding-left: 1ex;">
<div dir="ltr"><br />
<div><br />
<div>2017-12-19 10:13 GMT+01:00 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>:<br />
<blockquote style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid #cccccc; padding-left: 1ex;">
<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>
</div>
</div>
</blockquote>
<div>&nbsp;</div>
<div>I don't agree - there is not compatibility or portability reasons. The calculation using numeric operators is pretty simple, and possibility to create own function is here too.</div>
<div>&nbsp;</div>
<div>So there is not any reason to increase a postgresql catalogue.</div>
<div>&nbsp;</div>
<div>Please. don't do top post</div>
<div>&nbsp;</div>
<div>Regards</div>
<div>&nbsp;</div>
<div>Pavel</div>
<div>&nbsp;</div>
<blockquote style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid #cccccc; padding-left: 1ex;">
<div dir="rtl">
<div>
<div dir="rtl">
<div dir="ltr">&nbsp;</div>
<div dir="ltr">&nbsp;</div>
</div>
<section></section>
<blockquote style="margin: 0px 0px 20px; border-top: 1px solid #e0e0e0;"><br />ב דצמ׳ 18, 2017 18:28, Michael Nolan כתב:
<blockquote style="margin: 0px 0px 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">post= &lt; gresql(at)walla(dot)co(dot)il </a>&gt;</span> wrote:<br />
<blockquote style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid #cccccc; 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/doc<wbr />s/9.5/static/functions-math.ht<wbr />ml</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>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
<br />&gt;Percentage calculation exists in almost any databse and information system</div>
<div>&nbsp;</div>
<div>That is not exactly true. AFAIK, only Oracle has a Percentage function. SQL Server and MySQL do not. </div>
<div>It has already been shown that it is just as easy to code percentage inline&nbsp; (EG: SELECT (50.8 x 5.2) / 100 AS pct;&nbsp;&nbsp; ## .026416 </div>
<div>as it is to call a function SELECT pct(50.8, 5.2); </div>
<div>Please do not false statements to justify a request for a non-needed enhancement.</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>-- <br />
<div>
<div dir="ltr"><font size="4"><b><span style="font-family: courier new,monospace;">Melvin Davidson</span></b></font><br /><font style="font-weight: bold;" size="3"><span style="color: #8000ff;">I reserve the right to fantasize.&nbsp; Whether or not you </span><br style="color: #8000ff;" /> <span style="color: #8000ff;">wish to share my fantasy is entirely up to you. </span><img style="color: #8000ff;" src="https://api-mail.walla.co.il/proxy?url=http%3A%2F%2Fus.i1.yimg.com%2Fus.yimg.com%2Fi%2Fmesg%2Ftsmileys2%2F01.gif&amp;scr=992bfd131feaa60d9df456ec5778dc98" /></font></div>
</div>
</div>
</div>
</blockquote>
</blockquote>
</div></div>

Attachment Content-Type Size
unknown_filename text/html 5.9 KB

Browse pgsql-general by date

  From Date Subject
Next Message Uwe 2017-12-20 16:44:36 Re: postgresql 9.5 has ocuuered OOM
Previous Message Andreas Kretschmer 2017-12-20 16:25:00 Re: postgresql 9.5 has ocuuered OOM