Download ANALYTICS MANUAL
Transcript
Functions 251 Table 66: Functions Description (Continued) Function Description Logical Functions Select from the following to use a logical function in the expression: if(expression, then result, else result) This function returns the then result if expression is true; returns the else result if expression is false. For example, the expression if(incident.c$field=1, ‘Yes’, ‘No’) will return Yes for incidents where the value of c$field is 1; otherwise, No will be returned. Note: You can use IS NULL and IS NOT NULL as part of the expression. For example, you could use the expression if(incident.c$field IS NOT NULL, 'Yes', 'No'). decode(test expression, test value 1, result 1, [, next test value, next result]* [,default]) This function compares test expression to each test value in order and returns result for the first test value that expression matches. If expression does not match any test value, default will be returned; if default is undefined, NULL will be returned. The decode function can perform table lookups, allowing you to use text strings as test values rather than requiring coded values (for example, you can use Review as a test value for the expression faqs.status even though the table contains code value in the status column). nvl(expr1, expr2) If the value expr1 is null, this function returns the value expr2; however, if the value expr1 is not null, then the value expr1 is returned. The value of expr2 must match the data type of expr1. Math Functions Select from the following to use a math function in the expression: bitand(X, Y) This function returns the bitwise AND of two integers, X and Y. ceiling(X) This function returns the smallest integer value greater than or equal to X. floor(X) This function returns the largest integer less than or equal to X. power(X, Y) This function returns the value of X to the power of Y. For example, power(2,3) would return 8.