Substring functions: LEFT, RIGHT, SUBSTRING
These functions transform a string by retrieving a subset of its characters.
LEFT and RIGHT return the leftmost or rightmost n characters, respectively. Each takes the string as the first argument and the number of characters to retrieve as the second argument:
Varchar LEFT( value Varchar, offset Integer )
Varchar RIGHT( value Varchar, offset Integer )
Specifying an offset that is less than zero results in an error. If the offset is greater than the length of the string, these functions return the entire string.
SUBSTRING takes three arguments: the input string, the start position (one-based offset from the left side), and the number of characters to retrieve. It returns the substring located at this position:
Varchar SUBSTRING( input Varchar, start Integer, length Integer )
The following actions result in an error:
*
*
Examples
The following code:
SELECT CUSTOMERS.CUSTID, CUSTOMERS.CUSTOMNAME
FROM "../Data Sources/MyDatabase/CUSTOMERS.SMA" CUSTOMERS
WHERE LEFT(CUSTOMERS.CUSTOMNAME, 4) = 'Info'
returns:
109,InfoEngineering
117,InfoDesign
129,InfoSpecialists
The following code:
SELECT CUSTOMERS.CUSTID, CUSTOMERS.CUSTOMNAME
FROM "../Data Sources/MyDatabase/CUSTOMERS.SMA" CUSTOMERS
WHERE RIGHT(CUSTOMERS.CUSTOMNAME, 5) = 'Corp.'
returns:
104,SigniSpecialists Corp.
115,Design Solutions Corp.
118,Computer Systems Corp.
The following code:
SELECT CUSTOMERS.CUSTID, CUSTOMERS.CUSTOMNAME, SUBSTRING(CUSTOMERS.CUSTOMNAME, 2, 5)
FROM "../Data Sources/MyDatabase/CUSTOMERS.SMA" CUSTOMERS
returns:
101,Signal Engineering,ignal
102,Technical Specialists Co.,echni
104,SigniSpecialists Corp.,igniS

Additional Links:

Copyright Actuate Corporation 2012