💻 Introduction
Aggregate functions in SQL perform calculations on multiple rows and return a single value. They are often used with GROUP BY for summarizing data.
🔑 Common Aggregate Functions
COUNT()– Counts rowsSUM()– Calculates totalAVG()– Finds averageMIN()– Finds smallest valueMAX()– Finds largest value
📝 Example
SELECT
COUNT(*) AS total_employees,
SUM(salary) AS total_salary,
AVG(salary) AS avg_salary,
MIN(salary) AS lowest_salary,
MAX(salary) AS highest_salary
FROM Employees;
Tip: Aggregate functions ignore
NULL values (except COUNT(*)).✅ Key Takeaways
- Aggregate functions summarize data
- Often used with
GROUP BYandHAVING - They return a single value per group or query
📚 Continue Learning
💬 Questions about Aggregate Functions? Drop a comment!