Questions tagged [lpad]
10 questions
1
vote
1 answer
Laravel - Query Buider - SQL fields using LPAD statement
I'm cannot retry this query, in QueryBuilder:
select id, lpad(number, 12, 0), lpad(int, 2, 0) from users;
How I can, in the example not function...
DB::table('users') ->select('id', 'lpad(number, 12, 0)', 'lpad(int, 2, 0)' ->get();

Júnio Magalhães
- 13
- 2
1
vote
2 answers
LPAD function errors when used in WITH variable in Redshift
Can you tell me why this is throwing an error in Redshift?
WITH Testing_PADDING AS (SELECT '12345678' AS column1)
SELECT LPAD(column1, 9,'0') FROM Testing_PADDING;
Here is the error I receive:
"Invalid operation: failed to find conversion function…

SusanD
- 143
- 9
0
votes
1 answer
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…

Number1Rock
- 53
- 4
0
votes
1 answer
LPAD Ordering with decimals and varchar
Currently I'm trying to take a column from my database and trying to sort it so that the numbers that are in the column get ordered sequentially, and then the letters with numbers follow after. When I use the following statement
SELECT *
FROM…

Heroice18
- 1
- 2
0
votes
2 answers
Order By LPAD Issue
Currently I'm trying to take a list of values from my table and order them alphanumerically so they appear from number to letters. For example I have this data…

Heroice18
- 1
- 2
0
votes
1 answer
How to pad after split?
Help!
String all = "1.10.2";
String[] allArray = all.split("[.]");
What I want to do is make string "1.10.2" into 000010001000002 as integer.
00001 00010 00002
so giving padding and making each number into 5 digits and combining them as one…

Sang Kim
- 33
- 7
0
votes
0 answers
Pyspark using lpad not accepting length function
I am trying to add a prefix to a string column 'data' value with:
`df.select('data_id',lpad(df['data'],length(df.data) +3 ,'p1/'))`
But I got this error:
TypeError: 'Column' object is not callable
I tried casting with int(length(df.data)), but…

Stefani
- 1
- 1
0
votes
0 answers
LPAD without trimming for higher length strings
I have a requirement to query with following input and results.
MariaDB [db]> select LPAD('COMP1', 8, 'X');
+-----------------------+
| LPAD('COMP1', 8, 'X') |
+-----------------------+
| XXXCOMP1 |
+-----------------------+
In the…

ameenulla0007
- 2,663
- 1
- 12
- 15
-1
votes
1 answer
How to set the column default value to generate random 6 digit number
I want to generate 6 digit random number to a column when a new row added to the table. I tried the below query to set Default value to that column
ALTER TABLE test_table
ADD COLUMN test_column int(10) NOT NULL DEFAULT LPAD(FLOOR(RAND() *…

Sathya
- 233
- 1
- 4
- 13
-1
votes
1 answer
SQLBase: is there a lpad function?
I am using SQLBase and I have to complete a column with zeros.
This example works in PostgreSQL. I need to do the same in SQLBase but there isn't a function like lpad.
SELECT lpad(last_name, 10, '0')
FROM persons;
If last_name is Douglas, the…

Roby Sottini
- 2,117
- 6
- 48
- 88