LENGTH(a) 

LENGTH(a) is an arithmetic function that specifies the number of bytes that are required to represent the value a internally. The function can be applied to any data type.

 

Result of the LENGTH(a) function

a is character string with length n

n

The length is calculated without taking the following characters (code attribute ASCII, EBCDIC) or binary zeros (code attribute BYTE) into account.

a is NULL value

NULL value

a is special NULL value

Special NULL value

 

Model table: customer

The customer table is sorted according to the length of the surnames, with names with the same length sorted in alphabetical order.

SELECT surname, LENGTH(surname) length
FROM customer ORDER BY length, surname

NAME

LENGTH

DATASOFT

4

Porter

5

Brown

5

Brown

5

Howe

5

Griffith

5

Brown

5

Adams

5

Porter

6

Peters

6

Randolph

6

TOOLware

7

Peters

7

Jackson

7

Porter

7