Complete SQL Topics for Data Analysis
-> https://t.me/sqlspecialist/523
Today, we will learn about Aggregate Functions
Aggregation functions perform calculations on sets of values and return a single result. Common aggregation functions include:
#### COUNT():
Counts the number of rows in a result set.
SELECT COUNT(column) FROM table;#### SUM():
Calculates the sum of values in a column.
SELECT SUM(column) FROM table;#### AVG():
Calculates the average value of a numeric column.
SELECT AVG(column) FROM table;#### MAX():
Returns the maximum value in a column.
SELECT MAX(column) FROM table;#### MIN():
Returns the minimum value in a column.
SELECT MIN(column) FROM table;Example:
SELECT COUNT(order_id), AVG(total_amount) FROM orders WHERE customer_id = 123;This query counts the number of orders and calculates the average total amount for a specific customer.
Understanding aggregation is crucial for summarizing and analyzing data.
Share with credits: https://t.me/sqlspecialist
Hope it helps :)