Extracts a specified number of characters from the left (beginning) of a string. A more readable shorthand than SUBSTR for extracting leading characters.
STRINGDiperbarui: 13 Jun 2026LEFT(value, length)The source string
The number of characters to extract from the left
1 SELECT LEFT('BigQuery', 3) as result;
Extracts the first 3 characters.
1 SELECT 2 phone_number, 3 LEFT(phone_number, 3) as country_code 4 FROM `project.dataset.contacts` 5 WHERE phone_number LIKE '+1%' 6 LIMIT 3;
Extracts the country code from a phone number.
| phone_number | country_code |
|---|---|
| +12025551234 | +1 |
| +14155552345 | +1 |
1 SELECT 2 email, 3 CONCAT(LEFT(email, 3), '***@', SPLIT(email, '@')[OFFSET(1)]) as masked_email 4 FROM `project.dataset.users` 5 LIMIT 3;
Hides part of an email address for privacy.
| masked_email | |
|---|---|
| john.doe@gmail.com | joh***@gmail.com |
| jane@company.com | jan***@company.com |
1 SELECT 2 LEFT(sku, 2) as category, 3 COUNT(*) as product_count 4 FROM `project.dataset.products` 5 GROUP BY category 6 ORDER BY product_count DESC;
Groups products by their SKU prefix.
| category | product_count |
|---|---|
| EL | 450 |
| FA | 320 |
| FO | 280 |
Sudah paham LEFT? Latih langsung di browser
Latihan interaktif, langsung di browser.