Common Aggregate Functions in SQL

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



アプリ関連ニュース

お問い合わせはこちら

お問い合わせ・ご相談はお電話、またはお問い合わせフォームよりお受け付けいたしております。

tel. 06-6454-8833(平日 10:00~17:00)

お問い合わせフォーム