內置的聚合函數

  

返回類型

  

函數

說明

bigint

count(*) , count(expr), count(DISTINCT expr[,  expr_., expr_.])

返回記錄條數。

double

sum(col), sum(DISTINCT col)

求和

double

avg(col), avg(DISTINCT col)

求平均值

double

min(col)

返回指定列中最小值

double

max(col)

返回指定列中最大值

double

var_pop(col)

返回指定列的方差

double

var_samp(col)

返回指定列的樣本方差

double

stddev_pop(col)

返回指定列的偏差

double

stddev_samp(col)

返回指定列的樣本偏差

double

covar_pop(col1, col2)

兩列數值協方差

double

covar_samp(col1, col2)

兩列數值樣本協方差

double

corr(col1, col2)

返回兩列數值的相關係數

double

percentile(col, p)

返回數值區域的百分比數值點。0<=P<=1,否則返回NULL,不支持浮點型數值。

array<double>

percentile(col, array(p~1,,\ [, p,,2,,]…))

返回數值區域的一組百分比值分別對應的數值點。0<=P<=1,否則返回NULL,不支持浮點型數值。

double

percentile_approx(col, p[, B])

Returns an approximate p^th^ percentile of a  numeric column (including floating point types) in the group. The B parameter  controls approximation accuracy at the cost of memory. Higher values yield  better approximations, and the default is 10,000. When the number of distinct  values in col is smaller than B, this gives an exact percentile value.

array<double>

percentile_approx(col, array(p~1,, [, p,,2_]…)  [, B])

Same as above, but accepts and returns an array  of percentile values instead of a single one.

array<struct\{‘x’,'y’\}>

histogram_numeric(col, b)

Computes a histogram of a numeric column in the  group using b non-uniformly spaced bins. The output is an array of size b of  double-valued (x,y) coordinates that represent the bin centers and heights

array

collect_set(col)

返回無重複記錄

更多精彩內容請關注:http://bbs.superwu.cn 


關注超人學院微信二維碼:

關注超人學院java免費學習交流羣:


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章