Previous Topic Next topic Print topic


XRIGHT

ANSI DB2 SQL/DS XDB
      X

Extracts the last n characters from x. The format appears below:

XRIGHT(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, the following query retrieves phone numbers without the area codes:

SELECT XRIGHT(phone, 8)
FROM customer

If the value of n is longer than the string extracted, the string will be padded on the left with spaces until it is n characters long. For example, to right justify character strings, use a query like:

SELECT XRIGHT(pname, 14)
FROM part
column1
NUT
BOLT
CAM
SCREW
CAM
COG
Previous Topic Next topic Print topic