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!

How to generate unique 7 digit number with 0 padded in left

Orcl ApexMay 3 2023 — edited May 3 2023

Hi All,

I have a requirement to generate unique numbers up to 7 digits but they must be padded with 0. Please help me doing this in SQL.

Expected output

0000001

0000002

9999999

This is how I am trying to do but it always error out -

LPAD(ROW_NUMBER ()
OVER (
ORDER BY c1 DESC
)), 7, '0')

This post has been answered by Solomon Yakobson on May 3 2023
Jump to Answer
Comments
Post Details
Added on May 3 2023
5 comments
714 views