4.22 STRCMP

Use the @STRCMP function to compare two character columns or literal strings. Enclose literals within quotes.

@STRCMP returns the following:

  • -1 if the first string is less than the second.

  • 0 if the strings are equal.

  • 1 if the first string is greater than the second.

Trailing spaces are truncated before comparing the strings.

Syntax

@STRCMP (string1, string2)
string1

The first column or literal string to be compared.

string2

The second column or literal string to be compared.

Example

The following example compares two literal strings and returns 1 because the first string is greater than the second.

@STRCMP ("JOHNSON", "JONES")