Search Postgresql Archives

RE: Re: PostgreSQL needs percentage function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is exactly why I think there should be some build-in function for that...
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.
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.
 
 

ב דצמ׳ 18, 2017 18:28, Michael Nolan כתב:


On Mon, Dec 18, 2017 at 6:23 AM, Nick Dro <postgresql@xxxxxxxxxxx > 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
 
Seems like a nice addition to the math functions list:
 
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.
Seems like easy to implment isn't it?
 
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.
--
Mike Nolan

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux