XLEFT

ANSI DB2 SQL/DS XDB
      X

Extracts the n leftmost characters from a string. The format appears below:

XLEFT(x, n)

The parameter x is any expression that evaluates to a character string, and the parameter n is a positive integer indicating the number of characters to extract. For example, suppose you want to extract the area code from all customer phone numbers, you can use the query:

SELECT company, XLEFT(phone, 3)
FROM customer

If n is longer than the string extracted, the string is right padded with spaces until it is n characters long.

For example:

SELECT XLEFT(color, 10)||pname
FROM part
Column1
 
RED NUT
GREEN BOLT
BLUE CAM
RED SCREW
BLUE CAM
RED COG