ColumnStore Distributed Aggregate Functions

You are viewing an old version of this article. View the current version here.

MariaDB ColumnStore supports the following aggregate functions, these can be used in the SELECT, HAVING, and ORDER BY clauses of the SQL statement.

FunctionDescription
AVG([DISTINCT] column)Average value of a numeric (INT variations, NUMERIC, DECIMAL) column
COUNT (*, [DISTINCT] column)The number of rows returned by a query or grouping. All datatypes are supported
MAX ([DISTINCT] column)The maximum value of a column. All datatypes are supported.
MIN ([DISTINCT] column)The maximum value of a column. All datatypes are supported.
STD(), STDDEV(), STDDEV_POP()The population standard deviation of a numeric (INT variations, NUMERIC, DECIMAL) column
STDDEV_SAMP()The sample standard deviation of a numeric (INT variations, NUMERIC, DECIMAL) column
SUM([DISTINCT] column)The sum of a numeric (INT variations, NUMERIC, DECIMAL) column
VARIANCE(), VAR_POP()The population standard variance of a numeric (INT variations, NUMERIC, DECIMAL) column
VAR_SAMP()The population standard variance of a numeric (INT variations, NUMERIC, DECIMAL) column
REGR_AVGX(ColumnY, ColumnX)average of the independent variable (sum(ColumnX)/N), where N is number of rows processed by the query
REGR_AVGY(ColumnY, ColumnX)average of the dependent variable (sum(ColumnY)/N), where N is number of rows processed by the query
REGR_COUNT(ColumnY, ColumnX)The total number of input rows in which both column Y and column X are nonnull
REGR_SLOPE(ColumnY, ColumnX)The slope of the least-squares-fit linear equation determined by the (ColumnX, ColumnY) pairs
REGR_INTERCEPT(ColumnY, ColumnX)The y-intercept of the least-squares-fit linear equation determined by the (ColumnX, ColumnY) pairs
REGR_R2(ColumnY, ColumnX)square of the correlation coefficient. correlation coefficient is the regr_intercept(ColumnY, ColumnX) for linear model

An example group by query using aggregate functions is:

select year(o_orderdate) order_year, 
avg(o_totalprice) avg_totalprice, 
max(o_totalprice) max_totalprice, 
count(*) order_count 
from orders 
group by order_year 
order by order_year;

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.