Common Aggregate Functions in SQL
- 2020年6月15日
- 技術情報
Today I will talk about some common aggregate functions that are widely used in SQL programming language.
Count
if we want to get the count of all records or specific where condition records, we can get by using count function.
SELECT COUNT(column_name) FROM table_name
SELECT COUNT(column_name) FROM table_name WHERE condition;
AVG
For average rate calculations, we can use this.
SELECT AVG(column_name) FROM table_name;
SELECT AVG(column_name) FROM table_name WHERE condition;
SUM
For sum results of all records, we can use this.
SELECT SUM(column_name) FROM table_name
SELECT SUM(column_name) FROM table_name WHERE condition;
MIN
For specific minimum result of a column, we can use this.
SELECT MIN(column_name) FROM table_name;
SELECT MIN(column_name) FROM table_name WHERE condition;
Likewise min, we can use max to get maximum result.
SELECT MAX(column_name) FROM table_name;
SELECT MAX(column_name) FROM table_name WHERE condition;
By Yuuma
yuuma at 2020年06月15日 11:00:24