Common SQL Expressions For Saved Search

Character Functions

FunctionSyntaxDescription
CONCATCONCAT(char1, char2)returns char1 concatenated with char2
LOWERLOWER(char)returns char, with all letters lowercase
UPPERUPPERreturns char, with all letters uppercase
LTRIMLTRIM(char [, set ])removes from the left end of char all of the characters contained inset
RTRIMRTRIM(char [, set ])removes from the right end of char
SUBSTR{ SUBSTR| SUBSTRB| SUBSTRC}(char, position [, substring_length ])return a portion of char, beginning at character position, substring_length characters long
REPLACEREPLACE(char, search_string[,replacement_string ])Replace the character.

Numeric Functions

FunctionSyntaxDescription
ABSABS(n)returns the absolute value of n
CEILCEIL(n)returns smallest integer greater than or equal to n
FLOORFLOOR(n)returns largest integer equal to or less than n.
ROUNDROUND(n [, integer ])returns n rounded to integer places to the right of the decimal point
TRUNCTRUNC(n1 [, n2 ])returns n1 truncated to n2 decimal places
FunctionSyntaxDescription
NULLIF NULLIF(expr1, expr2)compares expr1 and expr2. If they are equal, then the function returns null. If they are not equal, then the function returns expr1.
NVLNVL(expr1, expr2)allows you to replace null with the second parameter
NVL2NVL2(expr1, expr2, expr3)If expr1 is not null, then NVL2 returns expr2. If expr1 is null, then NVL2 returns expr3.
DECODEDECODE(expr,search,result
[, search, result ]…
[, default ])
Compares expr to each search value one by one. If expr is equal to a search, the corresponding result is returned. If no match is found, default is returned.
CASECASE { expr WHEN comparison_expr THEN return_expr [ WHEN comparison_expr THEN return_expr ]… | WHEN condition THEN return_expr [ WHEN condition THEN return_expr ]… } [ ELSE else_expr ] ENDreturns value based on different conditions

Leave a comment

Your email address will not be published. Required fields are marked *