Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Pad Numbers with Zereos

zephyr223Feb 26 2010 — edited Feb 26 2010
Hi guys,
Here's my dilemma. I have a column in a table with TEST SCORE results. It's a raw score which i convert to a percentage. I am exporting a fixed lenght text document, and score needs to be of 6 spaces long. Here is the function i have to extract score

select UPPER(RPAD((SCORE/50)*100,6)) AS "SCORE" from test;

This works fine, but now i have been told i need to pad the number with zereos, so for example if the score is 96, the bosses would like to see it as 096.00, or 100 as 100.00, so then i wrote this:

select to_char((SCORE/50)*100, '000.00') from test;
The problem i am running across now is when i query the lenght of this column, for example,
select length(to_char((SCORE/50)*100, '000.00')) from test; I get that my SCORE is now being recognized as 7 characters instead of 6 which is not good... WHAT AM I DOING WRONG??? please help... Thanks in advance.
This post has been answered by Frank Kulash on Feb 26 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 26 2010
Added on Feb 26 2010
5 comments
1,108 views