Entering content frame

LENGTH(a) 

LENGTH(a) is an arithmetic function that specifies the number of characters or bytes that are required to represent the value a internally. The function can be used for all data types except LONG.

 

Result of the LENGTH(a) function

a is a value of data type CHAR|VARCHAR <ASCII|UNICODE> with n characters

Number of characters n

a is a value of another data type (other than LONG) of length n

Length n in bytes

a is a NULL value

NULL value

a is special NULL value

Special NULL value

The length of the number of characters or the length in bytes is determined without taking into account any trailing blanks (code attribute ASCII, UNICODE) or binary zeros (code attribute BYTE).

Example 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 name, LENGTH(name) mylength
FROM customer ORDER BY mylength, name

NAME

MYLENGTH

Howe

4

Adams

5

Brown

5

Brown

5

Brown

5

Peters

6

Peters

6

Porter

6

Porter

6

Porter

6

Jackson

7

DATASOFT

8

Griffith

8

Randolph

8

TOOLware

8

 

 

Leaving content frame