Junior
List the main aggregate functions.
sobes.tech AI
Answer from AI
The main aggregate functions in SQL:
COUNT()— counts the number of rows or values.SUM()— calculates the sum of values in a column.AVG()— calculates the average value.MIN()— finds the minimum value.MAX()— finds the maximum value.
These functions are often used with GROUP BY to group data and with HAVING to filter grouped results.
Example:
SELECT department, COUNT(*) AS employee_count, AVG(salary) AS avg_salary
FROM employees
GROUP BY department
HAVING AVG(salary) > 50000;