SQL Query a table and use LPAD for one column with dtype (smallint) to return values with leading 0's

314 Views Asked by At

There's about 25 columns and I want to query them all while formatting this one column to include leading zeros.

i.e julianday = 5 I want the data to show 005 julianday = 145 I want the data to show 145

SELECT LPAD(julianday, 3 ,'000') FROM date_db

My query comes back with an error: No matching function with signature lpad(smallint, tinyint, string)

1)What am I missing? 2)Can I use *, to query the entire table while formatting that one column?

1

There are 1 best solutions below

1
On

The first parameter in lpad needs to be a string so you would have to cast the date to a string, in the required format, before you can use it in lpad