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.
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.
So there is not any reason to increase a postgresql catalogue.
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
>Percentage calculation exists in almost any databse and information system
That is not exactly true. AFAIK, only Oracle has a Percentage function. SQL Server and MySQL do not.
It has already been shown that it is just as easy to code percentage inline (EG: SELECT (50.8 x 5.2) / 100 AS pct; ## .026416
as it is to call a function SELECT pct(50.8, 5.2);
Please do not false statements to justify a request for a non-needed enhancement.
--
Melvin Davidson I reserve the right to fantasize. Whether or not you wish to share my fantasy is entirely up to you.
--
Best Wishes,
Chris Travers
Efficito: Hosted Accounting and ERP. Robust and Flexible. No vendor lock-in.