String Functions

String Functions

CONCAT(exp1, exp2,..., expn)

This function adds two or more expressions together. Example: CONCAT("Welcome ", "to ", " Pranalytix!")="“Welcome to Pranalytix!"

LENGTH(x)

This function returns the length of a string (in bytes). Example: LENGTH("Pranalytix")=10

LOWER(x)

This function converts a string to lower-case.

LPAD(x, length, lpad_string)

This function left-pads a string with another string, to a certain length. Example: LPAD("abc/12345",3,"xxx")=abc/12xxx

LTRIM(x)

This function removes leading spaces from a string. Example: LTRIM("         Pranalytix Tutorial")="Pranalytix Tutorial"

POSITION(x IN y)

This function returns the position of the first occurrence of a sub-string in a string. If the sub-string is not found within the original string, this function returns 0. This function performs a case-insensitive search. Example: Search for "y" in string "Pranalytix.com", and return position: ...

REPLACE(x, FIND, REPL)

This function replaces all occurrences of a sub-string within a string, with a new sub-string. Note: This function performs a case-sensitive replacement. Example: Replace "Pranalitix " with "Pranalytix": REPLACE("Pranalitix Tutorial", "Pranalitix", "Pranalytix")=“Pranalytix Tutorial”

RPAD(x, length, lpad_string)

This function right-pads a string with another string, to a certain length. Example: Right-pad the string with "ABC", to a total length of 10: RPAD("Pranalytix Tutorial", 10, "ABC") Gives “ABCABCABCA Tutorial”

RTRIM(x)

This function removes trailing spaces from a string. Example: Remove trailing spaces from a string: RTRIM("Pranalytix Tutorial           “)=”Pranalytix Tutorial"

SUBSTRING(x, START, LEN)

This function extracts a sub-string from a string (starting at any position). Example: Extract a sub-string from a string (start at position 1, extract 10 characters): SUBSTRING("Pranalytix Tutorial", 1, 10)="Pranalytix"

TRIM(x)

This function removes leading and trailing spaces from a string. Example: Remove leading and trailing spaces from a string: TRIM(“     Pranalytix Tutorial      “)="Pranalytix Tutorial"

UPPER(x)

This function converts a string to upper-case. Example: UPPER("pranalytix")="PRANALYTIX"