Examples

Function definition

// _sortLimit is a helper function, which sorts and limits a table.
_sortLimit=(n,desc,columns=["_value"],tables=<-)=>tables|>sort(columns:columns,desc:desc)|>limit(n:n)// _highestOrLowest is a helper function which reduces all groups into a single
// group by specific tags and a reducer function. It then selects the highest or
// lowest records based on the columns and the _sortLimit function.
// The default reducer assumes no reducing needs to be performed.
_highestOrLowest=(n,_sortLimit,reducer,columns=["_value"],groupColumns=[],tables=<-)=>tables|>group(columns:groupColumns)|>reducer()|>group(columns:[])|>_sortLimit(n:n,columns:columns)highestAverage=(n,columns=["_value"],groupColumns=[],tables=<-)=>tables|>_highestOrLowest(n:n,columns:columns,groupColumns:groupColumns,reducer:(tables=<-)=>tables|>mean(columns:[columns[0]]),_sortLimit:top,)