Returns the number of characters in a string. For BYTES, returns the number of bytes.
INT64Diperbarui: 13 Jun 2026LENGTH(value)The string whose length will be measured
1 SELECT LENGTH('BigQuery') as len;
Counts the number of characters.
1 SELECT 2 username, 3 LENGTH(username) as username_length, 4 CASE 5 WHEN LENGTH(username) < 3 THEN 'Too short' 6 WHEN LENGTH(username) > 20 THEN 'Too long' 7 ELSE 'Valid' 8 END as validation 9 FROM `project.dataset.users`;
Validates username length.
| username | username_length | validation |
|---|---|---|
| jo | 2 | Too short |
| john_doe | 8 | Valid |
1 SELECT * 2 FROM `project.dataset.products` 3 WHERE LENGTH(description) > 100 4 AND LENGTH(description) < 500;
Finds products with medium-length descriptions.
Sudah paham LENGTH? Latih langsung di browser
Latihan interaktif, langsung di browser.