SQL 강좌 14.SQL COUNT(), AVG() and SUM() Functions

COUNT() : 특정 기준과 일치하는 행의 수를 센다.

AVG() : 숫자로 된 column의 평균 값을 반환한다.

SUM() : 숫자로 된 column의 합을 반환한다.

COUNT() Syntax

SELECT COUNT(column_name)
FROM table_name
WHERE condition;

AVG() Syntax

SELECT AVG(column_name)
FROM table_name
WHERE condition;

SUM() Syntax

SELECT SUM(column_name)
FROM table_name
WHERE condition;

COUNT() Example

SELECT COUNT(ProductID)
FROM Products;

AVG() Example

SELECT AVG(Price)
FROM Products;

SUM() Example

SELECT SUM(Quantity)
FROM OrderDetatils;

Comments