Oracle SQL: selecting integer values and returning them right padded and left justified

this might be an easy one: I'd like to select an integer data type, right pad with blanks so that there are 10 characters total and left-justify the output.

Select myInteger from table;
Should come out:
|999       |
(without the pipes but left justified and padded with blanks.

Who is Participating?
slightwv (䄆 Netminder)Connect With a Mentor Commented:
Just use rpad.

Note: I added the pipes so you can see the padding.
drop table tab1;
create table tab1 ( col1 number );

insert into tab1 values(999);

select '|' || rpad(col1,10,' ') || '|' from tab1;
awking00Connect With a Mentor Commented:
select rpad(to_char(yourintegerfield),10,' ')
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.