Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API
Returns the first n characters from a string.
Syntax
left(<string>, <n>)
Arguments
Required
<string>: The source string.<n>: The number of characters to return. When negative, returns all but the last |n| characters.
Returns
Returns a text value that contains the leftmost characters.
Considerations
- When n is negative, returns all but the last |n| characters.
- If n exceeds string length, returns the entire string.
Examples
Get First Characters
Extract the first two characters.
SELECT left('abcde', 2) AS result;
Returns 'ab'.