SQL(Aggregate Fuctions-집계함수)

김혜민·2024년 2월 14일

SQL

목록 보기
11/21

Aggregate Fuctions 집계함수
★ 집계함수는 Select or Group by 에서만 사용 가능!! ★

  • 여러 칼럼 혹은 테이블 전체 칼럼으로부터 하나의 결과값을 반환하는 함수

1. Count

select count(column)
from tablename
where conditions;

2. Sum

select sum(column)
from tablename
where conditions;

3. Avg

select avg(column)
from tablename
where conditions;

4. Min

select min(column)
from tablename
where conditions;

5. Max

select max(column)
from tablename
where conditions;

6. Group by

  • 그룹화하여 데이터를 조회
select column1, column2...
from table
where condition
group by column1, column2...
order by column1, column2...;

7. Having

  • 조건에 집계함수가 포함되는 경우 where 대신 having 사용
select column1, column2...
from table
where condition
group by column1, column2...
having condition(Aggregate Functions) <- ex> case_number>4000
order by column1, column2...;
profile
성장하는 주니어 데이터 분석가입니다!

0개의 댓글