Home > database >  How to Remove Leading "0" in a string in BigQuery?
How to Remove Leading "0" in a string in BigQuery?

Time:06-30

I am looking to remove the leading zeros in a string.

Below are my current results:

Department
026P-PLUMBING
0021-LUMBER
029B-KITCHEN AND BATH
025H-HARDWARE (25H)
0022-BUILDING MATERIALS

Below are my Desired Results:

Department
26P-PLUMBING
21-LUMBER
29B-KITCHEN AND BATH
25H-HARDWARE (25H)
22-BUILDING MATERIALS

CodePudding user response:

Use LTRIM(Department, '0') as in below example

select trim(Department, '0')
from your_table           

if applied to sample data in your question - output is

enter image description here

  • Related