Extracts a portion of characters from a string. Identical to SUBSTR, available for standard SQL compatibility.
STRINGDiperbarui: 13 Jun 2026SUBSTRING(value, position [, length])The string to extract from
The starting position (1-indexed). Negative values count from the end of the string
The number of characters to extract
1 SELECT SUBSTRING('BigQuery SQL', 1, 8) as result;
Extracts the first 8 characters.
1 SELECT 2 email, 3 SUBSTRING(email, STRPOS(email, '@') + 1) as domain 4 FROM `project.dataset.users` 5 LIMIT 3;
Extracts the domain portion from an email address.
| domain | |
|---|---|
| john@gmail.com | gmail.com |
| jane@company.co.id | company.co.id |
1 SELECT 2 file_name, 3 SUBSTRING(file_name, 1, LENGTH(file_name) - 4) as name_without_ext 4 FROM `project.dataset.files` 5 WHERE file_name LIKE '%.csv';
Removes the .csv extension from a file name.
| file_name | name_without_ext |
|---|---|
| sales_2024.csv | sales_2024 |
| report.csv | report |
Sudah paham SUBSTRING? Latih langsung di browser
Latihan interaktif, langsung di browser.