Home Python C Language C ++ HTML 5 CSS Javascript Java Kotlin SQL DJango Bootstrap React.js R C# PHP ASP.Net Numpy Dart Pandas Digital Marketing

SQL Aggregate



SQL Aggregate Functions


SQL aggregate functions are functions that perform a calculation on a set of values and return a single value. These functions are commonly used with the SELECT statement to compute summaries of data in a database. Here are some of the most commonly used SQL aggregate functions:

  1. COUNT(): Returns the number of rows that match a specified condition.


  2. SELECT COUNT(*) FROM table_name;
    SELECT COUNT(column_name) FROM table_name WHERE condition;

  3. SUM(): Returns the sum of values in a numeric column.


  4. SELECT SUM(column_name) FROM table_name WHERE condition;


  5. AVG(): Returns the average of values in a numeric column.


  6. SELECT AVG(column_name) FROM table_name WHERE condition;


  7. MIN(): Returns the minimum value in a column.


  8. SELECT MIN(column_name) FROM table_name WHERE condition;


  9. MAX(): Returns the maximum value in a column.


  10. SELECT MAX(column_name) FROM table_name WHERE condition;


    These functions can also be used together with the GROUP BY clause to perform aggregate calculations on groups of rows. For example:


    SELECT column_name, SUM(sales) FROM table_name GROUP BY column_name;

    This would return the sum of sales for each unique value in the column_name column.



Advertisement





Q3 Schools : India


Online Complier

HTML 5

Python

java

C++

C

JavaScript

Website Development

HTML

CSS

JavaScript

Python

SQL

Campus Learning

C

C#

java