add 0 if one digit in postgresql code example Example: postgresql add leading zeros SELECT lpad(42::text, 4, '0')