Bookshelf Home | Contents | Index | PDF |
Siebel Analytics Server Administration Guide > SQL Reference > SQL Reference > Aggregate FunctionsAggregate functions perform work on multiple values to create summary results. The aggregate functions cannot be used to form nested aggregation in expressions on logical columns that have a default aggregation rule defined in the Aggregation tab of the Logical Column dialog box. To specify nested aggregation, you need to define a column with a default aggregation rule and then request the aggregation of the column in a SQL statement. AvgCalculates the average (mean) value of an expression in a result set. Has to take a numeric expression as its argument. AvgDistinctCalculates the average (mean) of all distinct values of an expression. Has to take a numeric expression as its argument. BottomNRanks the lowest n values of the expression argument from 1 to n, 1 corresponding to the lowest numerical value. The BOTTOMN function operates on the values returned in the result set.
NOTE: A query can contain only one BOTTOMN expression. CountCalculates the number of rows having a nonnull value for the expression. The expression is typically a column name, in which case the number of rows with nonnull values for that column is returned. CountDistinctAdds distinct processing to the COUNT function. Count (*) (CountStar)For example, if a table named Facts contained 200,000,000 rows, the following query would return the following results: FirstSelects the first returned value of the numeric expression argument. The FIRST function is limited to defining dimension-specific aggregation rules in a repository. You cannot use it in SQL statements. The FIRST function operates at the most detailed level specified in your explicitly defined dimension. For example, if you have a time dimension defined with hierarchy levels day, month, and year, the FIRST function returns the first n days. You should not use the FIRST function as the first dimension-specific aggregate rule; doing so can cause poor performance because it might cause queries to bring back large numbers of rows for processing in the Siebel Analytics Server. GroupByColumnFor use in setting up aggregate navigation. It specifies the logical columns that define the level of the aggregate data existing in a physical aggregate table. For example, if an aggregate table contains data grouped by store and by month, specify the following syntax in the content filter (General tab of Logical Source dialog): The GROUPBYCOLUMN function is only for use in configuring a repository; you cannot use it to form SQL statements. GroupByLevelFor use in setting up aggregate navigation. It specifies the dimension levels that define the level of the aggregate data existing in a physical aggregate table. For example, if an aggregate table contains data at the store and month levels, and if you have defined dimensions (Geography and Customers) containing these levels, specify the following syntax in the content filter (General tab of Logical Source dialog): GROUPBYLEVEL (GEOGRAPHY.STORE, CUSTOMERS.MONTH) The GROUPBYLEVEL function is only for use in configuring a repository; you cannot use it to form SQL statements. LastSelects the last returned value of the numeric expression. The LAST function is limited to defining dimension-specific aggregation rules in a repository; you cannot use it in SQL statements. The LAST function operates at the most detailed level specified in your explicitly defined dimension. For example, if you have a time dimension defined with hierarchy levels day, month, and year, the LAST function returns the last n days. You should not use the LAST function as the first dimension-specific aggregate rule; doing so can cause poor performance because it might cause queries to bring back large numbers of rows for processing in the Siebel Analytics Server. MaxCalculates the maximum value (highest numeric value) of the rows satisfying the numeric expression argument. The MAX function resets its values for each group in the query, according to the rules outlined in Display Function Reset Behavior. MedianCalculates the median (middle) value of the rows satisfying the numeric expression argument. When there are an even number of rows, the median is the mean of the two middle rows. This function always returns a double. The MEDIAN function resets its values for each group in the query, according to the rules outlined in Display Function Reset Behavior. MinCalculates the minimum value (lowest numeric value) of the rows satisfying the numeric expression argument. The MIN function resets its values for each group in the query, according to the rules outlined in Display Function Reset Behavior. NTileThe NTILE function determines the rank of a value in terms of a user-specified range. It returns integers to represent any range of ranks. In other words, the resulting sorted data set is broken into a number of tiles where there are roughly an equal number of values in each tile. If the n_expression argument is not NULL, the function returns an integer that represents a rank within the requested range. NTile with n=100 returns what is commonly called the percentile (with numbers ranging from 1 to 100, with 100 representing the high end of the sort). This value is different from the results of the Siebel Analytics Server percentile function, which conforms to what is called percent rank in SQL 92 and returns values from 0 to 1. PercentileCalculates a percent rank for each value satisfying the numeric expression argument. The percent rank ranges are from 0 (1st percentile) to 1 (100th percentile), inclusive. The PERCENTILE function calculates the percentile based on the values in the result set of the query. The PERCENTILE function resets its values for each group in the query according to the rules outlined in Display Function Reset Behavior. RankCalculates the rank for each value satisfying the numeric expression argument. The highest number is assigned a rank of 1, and each successive rank is assigned the next consecutive integer (2, 3, 4,...). If certain values are equal, they are assigned the same rank (for example, 1, 1, 1, 4, 5, 5, 7...). The RANK function calculates the rank based on the values in the result set of the query. The RANK function resets its values for each group in the query according to the rules outlined in Display Function Reset Behavior. StdDevThe STDDEV function returns the standard deviation for a set of values. The return type is always a double. STDDEV([ALL | DISTINCT] n_expression)
There are two other functions that are related to STDDEV: STDDEV_POP([ALL | DISTINCT] n_expression) STDDEV_SAMP([ALL | DISTINCT] n_expression) STDDEV and STDDEV_SAMP are synonyms. The STDDEV function resets its values for each group in the query according to the rules outlined in Display Function Reset Behavior. SumCalculates the sum obtained by adding up all values satisfying the numeric expression argument. The SUM function resets its values for each group in the query according to the rules outlined in Display Function Reset Behavior. SumDistinctCalculates the sum obtained by adding all of the distinct values satisfying the numeric expression argument. TopNRanks the highest n values of the expression argument from 1 to n, 1 corresponding to the highest numerical value. The TOPN function operates on the values returned in the result set.
A query can contain only one TOPN expression. The TOPN function resets its values for each group in the query according to the rules outlined in Display Function Reset Behavior. |
Siebel Analytics Server Administration Guide |