Aggregate Function :
SQL provides several aggregate functions that allow us to perform calculations on a set of values and return a single result. Here is a list of commonly used aggregate functions in SQL:
- COUNT: This function counts the number of rows in a specified column or table. For example, to count the number of employees in a table called "employees", we can use the following query:
SELECT COUNT(*) FROM employees;
- SUM: This function calculates the sum of values in a specified column. For instance, to calculate the total sales amount from a table called "sales", we can use the following query:
SELECT SUM(amount) FROM sales;
- AVG: This function calculates the average value of a specified column. For example, to find the average salary of employees from a table called "employees", we can use the following query:
SELECT AVG(salary) FROM employees;
- MIN: This function returns the minimum value from a specified column. For instance, to find the minimum age from a table called "users", we can use the following query:
SELECT MIN(age) FROM users;
- MAX: This function returns the maximum value from a specified column. For example, to find the maximum price from a table called "products", we can use the following query:
SELECT MAX(price) FROM products;
These are just a few examples of aggregate functions in SQL. There are other functions like SUM, AVG, MIN, MAX, etc., that can be used to perform various calculations on data in SQL.
Thanks to read this post . if any query then simply drop a message.