1. COUNT():

    Example 1:

    sqlCopy code
    SELECT COUNT(*) AS total_orders
    FROM orders;
    
    

    Output: The total number of orders in the "orders" table.

    Example 2:

    sqlCopy code
    SELECT customer_id, COUNT(order_id) AS order_count
    FROM orders
    GROUP BY customer_id;
    
    

    Output: The count of orders for each customer.

  2. SUM():

    Example:

    sqlCopy code
    SELECT SUM(total_amount) AS total_sales
    FROM sales;
    
    

    Output: The total sales amount.

  3. AVG():

    Example:

    sqlCopy code
    SELECT AVG(score) AS average_score
    FROM exam_results;
    
    

    Output: The average exam score.

  4. MIN() and MAX():

    Example 1:

    sqlCopy code
    SELECT MIN(price) AS lowest_price
    FROM products;
    
    

    Output: The lowest product price.

    Example 2:

    sqlCopy code
    SELECT MAX(salary) AS highest_salary
    FROM employees;
    
    

    Output: The highest employee salary.

  5. GROUP_CONCAT() (MySQL-specific):

    Example:

    sqlCopy code
    SELECT department, GROUP_CONCAT(employee_name) AS employees_list
    FROM employees
    GROUP BY department;
    
    

    Output: A comma-separated list of employees' names in each department.

  6. STDEV() and VAR():

    Example:

    sqlCopy code
    SELECT department, STDEV(salary) AS salary_std_dev, VAR(salary) AS salary_variance
    FROM employees
    GROUP BY department;
    
    

    Output: The standard deviation and variance of salaries in each department.

  7. BIT_AND() and BIT_OR():

    Example:

    sqlCopy code
    SELECT department, BIT_AND(permission) AS all_permissions, BIT_OR(permission) AS any_permission
    FROM user_permissions
    GROUP BY department;
    
    

    Output: The combined bitwise AND and OR results for permissions in each department.

  8. COUNT(DISTINCT column):

    Example:

    sqlCopy code
    SELECT COUNT(DISTINCT product_category) AS unique_categories
    FROM products;
    
    

    Output: The count of unique product categories.

These aggregate functions are used to summarize and analyze data in SQL queries. They allow you to perform calculations on groups of rows, calculate statistics, and generate aggregated results based on specific criteria.