Page tree


Contents:

   

This example demonstrates functions that can be used to compare two sets of strings.

Functions:

ItemDescription
STRINGGREATERTHAN Function Returns true if the first string evaluates to be greater than the second string, based on a set of common collation rules.
STRINGGREATERTHANEQUAL Function Returns true if the first string evaluates to be greater than or equal to the second string, based on a set of common collation rules.
STRINGLESSTHAN Function Returns true if the first string evaluates to be less than the second string, based on a set of common collation rules.
STRINGLESSTHANEQUAL Function Returns true if the first string evaluates to be less than or equal to the second string, based on a set of common collation rules.
EXACT Function Returns true if the second string evaluates to be an exact match of the first string. Source values can be string literals, column references, or expressions that evaluate to strings.

Source:

The following table contains some example strings to be compared. 

rowIdstringAstringB
1aa
2aA
3ab
4a1
5a;
6;1
7a a
8aaa
9abcx

Note that in row #6, stringB begins with a space character.

Transformation:

For each set of strings, the following functions are applied to generate a new column containing the results of the comparison.

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula STRINGGREATERTHAN(stringA,stringB)
Parameter: New column name 'greaterThan'

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula STRINGGREATERTHANEQUAL(stringA,stringB)
Parameter: New column name 'greaterThanEqual'

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula STRINGLESSTHAN(stringA,stringB)
Parameter: New column name 'lessThan'

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula STRINGLESSTHANEQUAL(stringA,stringB)
Parameter: New column name 'lessThanEqual'

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula EXACT(stringA,stringB)
Parameter: New column name 'exactEqual'

 

Results:

In the following table, the Notes column has been added manually.

rowIdstringAstringBlessThanEquallessThangreaterThanEqualgreaterThanexactEqualNotes
1aatruefalsetruefalsetrueEvaluation of differences between STRINGLESSTHAN and STRINGGREATERTHAN and greater than versions.
2aAtruetruefalsefalsefalseComparisons are case-sensitive. Uppercase letters are greater than lowercase letters.
3abtruetruefalsefalsefalse
Letters later in the alphabet (b) are greater than earlier letters (a).
4a1falsefalse
true true false
Letters (a) are greater than digits (1).
5a;falsefalsetruetruefalseLetters (a) are greater than non-alphanumerics (;).
6;1truetruefalsefalsefalse

Digits (1) are greater than non-alphanumerics (;). Therefore, the following characters are listed in order of evaluation:

Aa1;
7a afalsefalsetruetruefalseLetters (and any non-breaking character) are greater than space values.
8aaatruetruefalsefalsefalseThe second string is greater, since it contains one additional string at the end.
9abcxtruetruefalsefalsefalseThe second string is greater, since its first letter is greater than the first letter of the first string.

See Also for EXAMPLE - String Comparison Functions:

This page has no comments.