Chapter 7. Scalar Functions and Aggregate Functions
Index:
type Value | Expected expr Format |
MICROSECOND[S] | MICROSECONDS |
MILLISECOND[S] | MILLISECONDS |
SECOND | SECONDS |
MINUTE | MINUTES |
HOUR | HOURS |
DAY | DAYS |
WEEK | WEEKS |
MONTH | MONTHS |
QUARTER | QUARTERS |
YEAR | YEARS |
DECADE | DECADES |
CENTURY | CENTURYS |
MILLENNIUM | MILLENNIUMS |
SECOND_MICROSECOND | 'SECONDS.MICROSECONDS' |
MINUTE_MICROSECOND | 'MINUTES.MICROSECONDS' |
MINUTE_SECOND | 'MINUTES:SECONDS' |
HOUR_MICROSECOND | 'HOURS.MICROSECONDS' |
HOUR_SECOND | 'HOURS:MINUTES:SECONDS' |
HOUR_MINUTE | 'HOURS:MINUTES' |
DAY_MICROSECOND | 'DAYS.MICROSECONDS' |
DAY_SECOND | 'DAYS HOURS:MINUTES:SECONDS' |
DAY_MINUTE | 'DAYS HOURS:MINUTES' |
DAY_HOUR | 'DAYS HOURS' |
YEAR_MONTH | 'YEARS-MONTHS' |
INTERVAL Value | Expected expr Format |
yyyy | Year |
q | Quarter |
m | Month |
y | Day of the year |
d | Day |
w | Weekday |
ww | Week |
h | Hour |
n | Minute |
s | Second |
type Value | Expected Result |
MICROSECOND[S] | MILLISECOND*1000 |
MILLISECOND[S] | indicats the millisecond within the second. |
SECOND | indicats the second within the minute |
MINUTE | MINUTES |
HOUR | HOURS |
DAY | DAYS |
MONTH | MONTHS |
QUARTER | QUARTERS |
YEAR | YEARS |
DECADE | DECADES |
CENTURY | CENTURYS |
MILLENNIUM | MILLENNIUMS |
DOW | indicates the day of the week, SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, and SATURDAY(1~7). |
DOY | indicates the day number within the year. The first day of the year has value 1. |
WEEK,WOM | indicats the ordinal number of the day of the week within the current month. |
WOY | indicats the ordinal number of the day of the week within the current year. |
EPOCH | the current time as UTC milliseconds from the epoch(1970-01-01 00:00:00). |
Function Argument Type Return Type DescriptionREGEXP_LIKE(expression,pattern[,match_parameter])
expression is a string expression that serves as the search value.
pattern is the regular expression. For a listing of the operators you can specify in pattern, refer to java.util.regex.Matcher.Pattern.
match_parameter is a text literal that lets you change the default matching behavior of the function. You can specify one or more of the following values for match_parameter:
'i' specifies case-insensitive matching.
'c' specifies case-sensitive matching.
'n' allows the period (.), which is the match-any-character wildcard character, to match the newline character. If you omit this parameter, then the period does not match the newline character.
'm' treats the source string as multiple lines. HXTT Text (CSV) interprets ^ and $ as the start and end, respectively, of any line anywhere in the source string, rather than only at the start or end of the entire source string. If you omit this parameter, then HXTT Text (CSV) treats the source string as a single line.
'x' ignores whitespace characters. By default, whitespace characters match themselves.
If you specify multiple contradictory values, then HXTT Text (CSV) uses the last value. For example, if you specify 'ic', then HXTT Text (CSV) uses case-sensitive matching. If you specify a character other than those shown above, then HXTT Text (CSV) will ignore it.
If you omit match_parameter, then:
The default case sensitivity is determined by the value of the caseInsensitive connection property.
A period (.) does not match the newline character.
The source string is treated as a single line.return true if it find one subsequence matches the pattern. REGEXP_LIKE is similar to the LIKE condition, except REGEXP_LIKE performs regular expression matching instead of the simple pattern matching performed by LIKE. This condition evaluates strings using characters as defined by the charSet connection property. REGEXP_REPLACE(source_expression,pattern[, cReplacement[, nStartOccurrence [, nNumberOfOccurrences[,match_parameter]]]])
source_expression is a string expression that serves as the search value.
pattern is the regular expression. IFor a listing of the operators you can specify in pattern, refer to java.util.regex.Matcher.Pattern.
cReplacement may contain references to subsequences captured during the previous match: Each occurrence of $g will be replaced by the result of evaluating group(g). The first number after the $ is always treated as part of the group reference. Subsequent numbers are incorporated into g if they would form a legal group reference. Only the numerals '0' through '9' are considered as potential components of the group reference. If the second group matched the string "foo", for example, then passing the replacement string "$2bar" would cause "foobar" to be appended to the string buffer. A dollar sign ($) may be included as a literal in the replacement string by preceding it with a backslash (\$).
nStartOccurrence is a positive integer indicating the character of source_expression where HXTT Text (CSV) should begin the search. The default is 1, meaning that HXTT Text (CSV)begins the search at the first character of source_expression.
nNumberOfOccurrences is a nonnegative integer indicating the occurrence of the replace operation:
If you specify 0, then HXTT Text (CSV) replaces all occurrences of the match.
If you specify a positive integer n, then HXTT Text (CSV) replaces the nth occurrence.
If occurrence is greater than 1, then the database searches for the second occurrence beginning with the first character following the first occurrence of pattern, and so forth. This behavior is different from the INSTR function, which begins its search for the second occurrence at the second character of the first occurrence.
match_parameter is a text literal that lets you change the default matching behavior of the function. You can specify one or more of the following values for match_parameter:
'i' specifies case-insensitive matching.
'c' specifies case-sensitive matching.
'n' allows the period (.), which is the match-any-character wildcard character, to match the newline character. If you omit this parameter, then the period does not match the newline character.
'm' treats the source string as multiple lines. HXTT Text (CSV) interprets ^ and $ as the start and end, respectively, of any line anywhere in the source string, rather than only at the start or end of the entire source string. If you omit this parameter, then HXTT Text (CSV) treats the source string as a single line.
'x' ignores whitespace characters. By default, whitespace characters match themselves.
If you specify multiple contradictory values, then HXTT Text (CSV) uses the last value. For example, if you specify 'ic', then HXTT Text (CSV) uses case-sensitive matching. If you specify a character other than those shown above, then HXTT Text (CSV) will ignore it.
If you omit match_parameter, then:
The default case sensitivity is determined by the value of the caseInsensitive connection property.
A period (.) does not match the newline character.
The source string is treated as a single line.searches a character expression for occurrences of a pattern, and then replaces each occurrence with a third pattern expression. REGEXP_REPLACE extends the functionality of the STRTRAN function by letting you search a string for a regular expression pattern. By default, the function returns source_expression with every occurrence of the regular expression pattern replaced with replace_string. The string returned is in the same character set as source_expression. REGEXP_INSTR(source_expression,pattern[, nStartOccurrence [, nNumberOfOccurrences[,return_option,[,match_parameter[,subexpr ]]]]])
source_expression is a string expression that serves as the search value.
pattern is the regular expression. IFor a listing of the operators you can specify in pattern, refer to java.util.regex.Matcher.Pattern.
nStartOccurrence is a positive integer indicating the character of source_expression where HXTT Text (CSV) should begin the search. The default is 1, meaning that HXTT Text (CSV)begins the search at the first character of source_expression.
nNumberOfOccurrences is a nonnegative integer indicating the occurrence of the replace operation:
If you specify 0, then HXTT Text (CSV) replaces all occurrences of the match.
If you specify a positive integer n, then HXTT Text (CSV) replaces the nth occurrence.
If occurrence is greater than 1, then the database searches for the second occurrence beginning with the first character following the first occurrence of pattern, and so forth. This behavior is different from the INSTR function, which begins its search for the second occurrence at the second character of the first occurrence.
return_option lets you specify what HXTT Text (CSV) should return in relation to the occurrence:
If you specify 0, then HXTT Text (CSV) returns the position of the first character of the occurrence. This is the default.
If you specify 1, then HXTT Text (CSV) returns the position of the character following the occurrence.
match_parameter is a text literal that lets you change the default matching behavior of the function. You can specify one or more of the following values for match_parameter:
'i' specifies case-insensitive matching.
'c' specifies case-sensitive matching.
'n' allows the period (.), which is the match-any-character wildcard character, to match the newline character. If you omit this parameter, then the period does not match the newline character.
'm' treats the source string as multiple lines. HXTT Text (CSV) interprets ^ and $ as the start and end, respectively, of any line anywhere in the source string, rather than only at the start or end of the entire source string. If you omit this parameter, then HXTT Text (CSV) treats the source string as a single line.
'x' ignores whitespace characters. By default, whitespace characters match themselves.
If you specify multiple contradictory values, then HXTT Text (CSV) uses the last value. For example, if you specify 'ic', then HXTT Text (CSV) uses case-sensitive matching. If you specify a character other than those shown above, then HXTT Text (CSV) will ignore it.
If you omit match_parameter, then:
The default case sensitivity is determined by the value of the caseInsensitive connection property.
A period (.) does not match the newline character.
The source string is treated as a single line. For a pattern with subexpressions, the subexpr is a fragment of pattern enclosed in parentheses. Subexpressions can be nested. Subexpressions are numbered in order in which their left parentheses appear in pattern. For example, consider the following expression:
0123(((abc)(de)f)ghi)45(678)
This expression has five subexpressions in the following order: "abcdefghi" followed by "abcdef", "abc", "de" and "678".
If subexpr is zero, then the position of the entire substring that matches the pattern is returned. If subexpr is greater than zero, then the position of the substring fragment that corresponds to subexpression number subexpr in the matched substring is returned. If pattern does not have at least subexpr subexpressions, the function returns zero. The default value for subexpr is zero.
returns the position of the first character of the occurrence or the character following the occurrence. REGEXP_INSTR extends the functionality of the INSTR function by letting you search a string for a regular expression pattern. It returns an integer indicating the beginning or ending position of the matched substring, depending on the value of the return_option argument. If no match is found, then the function returns 0. REGEXP_SUBSTR (source_expression,pattern[, nStartOccurrence [, nNumberOfOccurrences[,match_parameter[,subexpr ]]]]))
source_expression is a string expression that serves as the search value.
pattern is the regular expression. IFor a listing of the operators you can specify in pattern, refer to java.util.regex.Matcher.Pattern.
nStartOccurrence is a positive integer indicating the character of source_expression where HXTT Text (CSV) should begin the search. The default is 1, meaning that HXTT Text (CSV)begins the search at the first character of source_expression.
nNumberOfOccurrences is a nonnegative integer indicating the occurrence of the replace operation:
If you specify 0, then HXTT Text (CSV) replaces all occurrences of the match.
If you specify a positive integer n, then HXTT Text (CSV) replaces the nth occurrence.
If occurrence is greater than 1, then the database searches for the second occurrence beginning with the first character following the first occurrence of pattern, and so forth. This behavior is different from the INSTR function, which begins its search for the second occurrence at the second character of the first occurrence.
match_parameter is a text literal that lets you change the default matching behavior of the function. You can specify one or more of the following values for match_parameter:
'i' specifies case-insensitive matching.
'c' specifies case-sensitive matching.
'n' allows the period (.), which is the match-any-character wildcard character, to match the newline character. If you omit this parameter, then the period does not match the newline character.
'm' treats the source string as multiple lines. HXTT Text (CSV) interprets ^ and $ as the start and end, respectively, of any line anywhere in the source string, rather than only at the start or end of the entire source string. If you omit this parameter, then HXTT Text (CSV) treats the source string as a single line.
'x' ignores whitespace characters. By default, whitespace characters match themselves.
If you specify multiple contradictory values, then HXTT Text (CSV) uses the last value. For example, if you specify 'ic', then HXTT Text (CSV) uses case-sensitive matching. If you specify a character other than those shown above, then HXTT Text (CSV) will ignore it.
If you omit match_parameter, then:
The default case sensitivity is determined by the value of the caseInsensitive connection property.
A period (.) does not match the newline character.
The source string is treated as a single line.
For a pattern with subexpressions, the subexpr is a fragment of pattern enclosed in parentheses. Subexpressions can be nested. Subexpressions are numbered in order in which their left parentheses appear in pattern. For example, consider the following expression:
0123(((abc)(de)f)ghi)45(678)
This expression has five subexpressions in the following order: "abcdefghi" followed by "abcdef", "abc", "de" and "678".
If subexpr is zero, then the position of the entire substring that matches the pattern is returned. If subexpr is greater than zero, then the position of the substring fragment that corresponds to subexpression number subexpr in the matched substring is returned. If pattern does not have at least subexpr subexpressions, the function returns zero. The default value for subexpr is zero.
returns the substring of the occurrence. REGEXP_SUBSTR extends the functionality of the SUBSTR function by letting you search a string for a regular expression pattern. It returns the substring itself. This function is useful if you need the contents of a match string but not its position in the source string. REGEXP_COUNT(source_expression,pattern[, nStartOccurrence[,match_parameter]])
source_expression is a string expression that serves as the search value.
pattern is the regular expression. IFor a listing of the operators you can specify in pattern, refer to java.util.regex.Matcher.Pattern.
nStartOccurrence is a positive integer indicating the character of source_expression where HXTT Text (CSV) should begin the search. The default is 1, meaning that HXTT Text (CSV)begins the search at the first character of source_expression.
match_parameter is a text literal that lets you change the default matching behavior of the function. You can specify one or more of the following values for match_parameter:
'i' specifies case-insensitive matching.
'c' specifies case-sensitive matching.
'n' allows the period (.), which is the match-any-character wildcard character, to match the newline character. If you omit this parameter, then the period does not match the newline character.
'm' treats the source string as multiple lines. HXTT Text (CSV) interprets ^ and $ as the start and end, respectively, of any line anywhere in the source string, rather than only at the start or end of the entire source string. If you omit this parameter, then HXTT Text (CSV) treats the source string as a single line.
'x' ignores whitespace characters. By default, whitespace characters match themselves.
If you specify multiple contradictory values, then HXTT Text (CSV) uses the last value. For example, if you specify 'ic', then HXTT Text (CSV) uses case-sensitive matching. If you specify a character other than those shown above, then HXTT Text (CSV) will ignore it.
If you omit match_parameter, then:
The default case sensitivity is determined by the value of the caseInsensitive connection property.
A period (.) does not match the newline character.
The source string is treated as a single line.returns the number of times a pattern occurs in a source string. REGEXP_COUNT returns the number of times a pattern occurs in a source string. It returns an integer indicating the number of occurrences of pattern. If no match is found, then the function returns 0.
Function Argument Type Return Type DescriptionDECODE( expression , search , result [, search , result]... [, default] )
expression is the value to compare. search is the value that is compared against expression. result is the value returned, if expression is equal to search. default is optional. If no matches are found, the decode will return default. If default is omitted, then the decode statement will return null (if no matches are found). same as argument type The decode function has the functionality of an IF-THEN-ELSE statement. GREATEST(expression1,expression2[,...])
MAX(expression1,expression2[,...])
any numeric, string, date/time, or boolean type same as argument type maximum value of all expressions LEAST(expression1,expression2[,...])
MIN(expression1,expression2[,...])
any numeric, string, date/time, or boolean type same as argument type minimum value of all expressions IF(lExpression, eExpression1, eExpression2)
IIF(lExpression, eExpression1, eExpression2)
lExpression specifies the logical expression that IF()/IIF( ) evaluates.
Returns one of two values depending on the value of a logical expression.
If lExpression evaluates to true , eExpression1 is returned. If lExpression evaluates to false, eExpression2 is returned. NVL(expression, value)
IFNULL(expression, value)
any numeric, string, date/time, or boolean type Returns one of two values depending on whether expression is null. If expression evaluates to null , value is returned. Otherwise, expression is returned. INLIST(eExpression1, eExpression2 [, eExpression3 ...]) eExpression1 specifies the expression INLIST( ) searches for in the set of expressions. eExpression2 [, eExpression3 ...] specifies the set of expressions to search. You must include at least one expression (eExpression2), and can include up to 24 expressions (eExpression2, eExpression3, and so on). Determines whether an expression matches another expression in a set of expressions. All the expressions in the set of expressions must be of the same data type.
COALESCE(value [, ...]) any numeric, string, date/time, or boolean type the type of the first of its arguments that is not null returns the first of its arguments that is not null ELT(numberExpression,value1Expression,[value2Expression,...]) numberExpression must be a integer type,value expression can be any type Returns value depending on the numberExpression,value1Expression,...valuexExpression Returns value1Expression if numberExpression = 1, value2Expression if numberExpression = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. INTERVAL(expression,expr1,expr2,...,exprn) any numeric, string, date/time, or boolean type integer value returns 0 if expression< expr1, 1 if expression< expr2 and so on or -1 if expressionN is NULL. If expression>exprn, returns n. TRANSFER (expression, search_1, result_1)
TRANSFER (expression, search_1, result_1, search_2, result_2)
TRANSFER (expression, search_1, result_1, search_2, result_2, ...., search_n, result_n)
TRANSFER (expression, search_1, result_1, default)
TRANSFER (expression, search_1, result_1, search_2, result_2, default)
TRANSFER (expression, search_1, result_1, search_2, result_2, ...., search_n, result_n, default)any numeric, string, date/time, or boolean type,or null Returns value depending on the expression,search_x,result_x and default TRANSFER compares expression to the search_x expressions and, if matches, returns result_x. If not, returns default, or, if default is left out, return null . SWITCH ( expression1, value1, expression2, value2, ... expression_n, value_n ) any numeric, string, date/time, or boolean type,or null Evaluates a list of expressions and returns the corresponding value for the first expression in the list that is TRUE. SWITCH compares expression to the expression_n expressions and, if matches, returns value_n. If not, returns null . TRANSFORM(expression [, formatcodes]) expression specifies the character, currency, date, or numeric expression to format.
formatcode specifies one format code that determine how the expression is formatted. The following table lists the available format codes
Format Code Description @C CR is appended to positive currency or numeric values to indicate a credit. @D act as DTOS function. @E act as DTOS function. @T leading and trailing spaces are trimmed from character values. @X db is appended to negative currency or numeric values to indicate a debit. @Z if 0, currency or numeric values are converted to spaces. @( encloses negative currency or numeric values in parentheses. @^ converts currency or numeric values to scientific notation. @0 converts numeric or currency values to their hexadecimal equivalents. The numeric or currency value must be positive and less than 4,294,967,296. ! converts a character to uppercase. $ adds the current currency symbol specified by SET CURRENCY to currency and numeric values. By default, the symbol is placed immediately before or after the value. However, the currency symbol and its placement (specified with SET CURRENCY), the separator character (specified with SET SEPARATOR) and the decimal character (specified with SET POINT) can all be changed. X specifies the width of character values. For example, if cFormatCodes is XX? 2 characters are returned. Y converts logical true (.T.) and false (.F.) values to Y and N, respectively. @! converts a string to uppercase. return the formatted string returns a character string from an expression in a format determined by a format code