Padding zeros to the left in postgreSQL

后端 未结 3 1696
滥情空心
滥情空心 2020-12-12 23:24

I am relatively new to PostgreSQL and I know how to pad a number with zeros to the left in SQL Server but I\'m struggling to figure this out in PostgreSQL.

I have a

3条回答
  •  北海茫月
    2020-12-12 23:44

    As easy as

    SELECT lpad(42::text, 4, '0')
    

    References:

    • http://www.postgresql.org/docs/current/static/functions-string.html

    sqlfiddle: http://sqlfiddle.com/#!15/d41d8/3665

提交回复
热议问题