Part 05. SQL_Chapter 15. Aggregate Functions(집계함수)

수야·2023년 7월 31일
0

sum

숫자 컬럼의 합계 도출

select sum(column)
from tablename
where condtion;

avg

숫자 컬럼의 평균 도출

select avg(column)
from tablename
where condition

min

숫자 컬럼 중 가장 작은 수 도출

select min(column)
from table
where condition;

max

숫자 컬럼 중 가장 큰 수 도출

select max(column)
from tablename
where condition;

group by

그룹화 하여 데이터를 조회
그룹 별 데이터 조회

select column1, column2,...
from tablename
where condition
group by column1 , column2,... #그룹핑할텐데 중복이 제거될거임
order by column1, column2,...

오잉 그럼 중복 제거에 distinct 써도 되는거 아냐?

select distinct column1,column2,...
from tablename
# 그러나 orde by를 쓸 수 없음

having

조건에 집계함수가 포함되는 경우 where대신 having 사용

select column1, column2,...
from tablename
where condition
group by column1, column2,...
having contion (aggregate functions)
order by column1, column2,...
profile
수야는 코린이에서 더 나아갈거야

1개의 댓글

comment-user-thumbnail
2023년 7월 31일

잘 읽었습니다. 좋은 정보 감사드립니다.

답글 달기