IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Aggregate Functions
editAggregate Functions
editBasic
edit-
Average (
AVG
)
SELECT AVG(salary) AS avg FROM test_emp;
-
Count the number of matching fields (
COUNT
)
SELECT COUNT(*) AS count FROM test_emp;
-
Count the number of distinct values in matching documents (
COUNT(DISTINCT
)
SELECT COUNT(DISTINCT hire_date) AS count FROM test_emp;
-
Find the maximum value in matching documents (
MAX
)
SELECT MAX(salary) AS max FROM test_emp;
-
Find the minimum value in matching documents (
MIN
)
SELECT MIN(emp_no) AS min FROM test_emp;
-
Sum
all values of matching documents (
SUM
).
SELECT SUM(salary) FROM test_emp;