'SQL Query a table and use LPAD for one column with dtype (smallint) to return values with leading 0's
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?
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | NickW |
