Junior — Middle
Can you name the main aggregate functions used in SQL for data processing?
sobes.tech AI
Answer from AI
Main aggregate functions in SQL used for data processing:
- COUNT() — counts the number of rows in a dataset or the number of values in a column.
- SUM() — calculates the sum of values in a numeric column.
- AVG() — calculates the average value of a column.
- MIN() — finds the minimum value in a column.
- MAX() — finds the maximum value in a column.
Example of using aggregate functions:
SELECT department, COUNT(*) AS employee_count, AVG(salary) AS average_salary
FROM employees
GROUP BY department;
This query counts the number of employees and the average salary for each department.