Class AggregateFunctions


  • @Experimental
    @Public
    public class AggregateFunctions
    extends Object
    DSL for N1QL functions in the aggregate category. Aggregate functions take multiple values from documents, perform calculations, and return a single value as the result. You can only use aggregate functions in SELECT, LETTING, HAVING, and ORDER BY clauses. When using an aggregate function in a query, the query operates as an aggregate query. See N1QL reference documentation: http://docs.couchbase.com/4.0/n1ql/n1ql-language-reference/aggregatefun.html
    Since:
    2.2
    Author:
    Simon Baslé
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Expression arrayAgg​(Expression expression)
      Returned expression results in a array of the non-MISSING values in the group, including NULLs.
      static Expression arrayAgg​(String expression)
      Returned expression results in a array of the non-MISSING values in the group, including NULLs.
      static Expression avg​(Expression expression)
      Returned expression results in the arithmetic mean (average) of all the distinct number values in the group.
      static Expression avg​(String expression)
      Returned expression results in the arithmetic mean (average) of all the distinct number values in the group.
      static Expression count​(Expression expression)
      Returned expression results in count of all the non-NULL and non-MISSING values in the group.
      static Expression count​(String expression)
      Returned expression results in count of all the non-NULL and non-MISSING values in the group
      static Expression countAll()
      Returned expression results in a count of all the input rows for the group, regardless of value (including NULL).
      static Expression distinct​(Expression expression)
      prefixes an expression with DISTINCT, useful for example for distinct count "COUNT(DISTINCT expression)".
      static Expression distinct​(String expression)
      prefixes an expression with DISTINCT, useful for example for distinct count "COUNT(DISTINCT expression)".
      static Expression max​(Expression expression)
      Returned expression results in the maximum non-NULL, non-MISSING value in the group in N1QL collation order.
      static Expression max​(String expression)
      Returned expression results in the maximum non-NULL, non-MISSING value in the group in N1QL collation order.
      static Expression min​(Expression expression)
      Returned expression results in the minimum non-NULL, non-MISSING value in the group in N1QL collation order.
      static Expression min​(String expression)
      Returned expression results in the minimum non-NULL, non-MISSING value in the group in N1QL collation order.
      static Expression sum​(Expression expression)
      Returned expression results in the sum of all the number values in the group.
      static Expression sum​(String expression)  
    • Method Detail

      • arrayAgg

        public static Expression arrayAgg​(Expression expression)
        Returned expression results in a array of the non-MISSING values in the group, including NULLs.
      • arrayAgg

        public static Expression arrayAgg​(String expression)
        Returned expression results in a array of the non-MISSING values in the group, including NULLs.
      • avg

        public static Expression avg​(Expression expression)
        Returned expression results in the arithmetic mean (average) of all the distinct number values in the group.
      • avg

        public static Expression avg​(String expression)
        Returned expression results in the arithmetic mean (average) of all the distinct number values in the group.
      • count

        public static Expression count​(Expression expression)
        Returned expression results in count of all the non-NULL and non-MISSING values in the group.
      • count

        public static Expression count​(String expression)
        Returned expression results in count of all the non-NULL and non-MISSING values in the group
      • countAll

        public static Expression countAll()
        Returned expression results in a count of all the input rows for the group, regardless of value (including NULL).
      • max

        public static Expression max​(Expression expression)
        Returned expression results in the maximum non-NULL, non-MISSING value in the group in N1QL collation order.
      • max

        public static Expression max​(String expression)
        Returned expression results in the maximum non-NULL, non-MISSING value in the group in N1QL collation order.
      • min

        public static Expression min​(Expression expression)
        Returned expression results in the minimum non-NULL, non-MISSING value in the group in N1QL collation order.
      • min

        public static Expression min​(String expression)
        Returned expression results in the minimum non-NULL, non-MISSING value in the group in N1QL collation order.
      • sum

        public static Expression sum​(Expression expression)
        Returned expression results in the sum of all the number values in the group.
      • distinct

        public static Expression distinct​(Expression expression)
        prefixes an expression with DISTINCT, useful for example for distinct count "COUNT(DISTINCT expression)".
      • distinct

        public static Expression distinct​(String expression)
        prefixes an expression with DISTINCT, useful for example for distinct count "COUNT(DISTINCT expression)".