sql / beginner
Snippet
Counting Characters in Text with CHARACTER_LENGTH
The ANSI standard CHARACTER_LENGTH scalar function evaluates a string column and returns the exact count of characters in each row.
snippet.sql
sql
1
2
SELECT product_name, CHARACTER_LENGTH(product_name) AS name_lengthFROM products;
Breakdown
1
SELECT product_name, CHARACTER_LENGTH(product_name) AS name_length
Retrieves product_name and computes its character length, aliasing the output as name_length.
2
FROM products;
Identifies products as the source table for evaluation.