How to add leading zero in a number in oracle sql query?

by darrion.kuhn , in category: MySQL , 9 months ago

How to add leading zero in a number in oracle sql query?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by shyann , 9 months ago

@darrion.kuhn 

You can add a leading zero to a number in Oracle SQL query using the LPAD function. Here is an example query to add a leading zero to a number:

1
SELECT LPAD(9, 2, '0') AS padded_number FROM dual;


In this query, the LPAD function takes three parameters: the number to pad (in this case, 9), the total length of the padded string (in this case, 2), and the character to pad with (in this case, '0'). The result of this query will be '09'.