The Vertica Forum recently got a makeover! Let us know what you think by filling out this short, anonymous survey.
Please take this survey to help us learn more about how you use third party tools. Your input is greatly appreciated!

How to trim leading 0s

Hello

I am having hard time finding code to remove leading zeros. An example of the string is '00001234' and '0012345'. I need to remove leading zeros to show '1234' and '12345' respectively. Any help?

Thanks
VJ

Answers

  • SruthiASruthiA Vertica Employee Employee

    Hi,

      Please check the below solution. 
    

    dbadmin=>select trim(LEADING '0' FROM '00012345');

    ltrim

    12345
    (1 row)

    dbadmin=> select trim(LEADING '0' FROM '0000001234');

    ltrim

    1234
    (1 row)

  • that worked, thank you very much

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file