Aggregate Function (집계 함수)

hh_binvely·2024년 3월 17일
0

Part 03. SQL

목록 보기
9/11
post-thumbnail

Aggregate Function (집계 함수)

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

1. Count

  • 총 갯수를 계산해주는 함수

    생성 문법

    select count(column)
    from tablename
    where condition;
  • uniq 개수
    select count(distinct column)
    from tablename
    where condition;

2. Sum

  • 숫자 컬럼의 합계를 계산해주는 함수
select sum(column)
from tablename
where condition;

3. AVG

  • 숫자 컬럼의 평균을 계산해주는 함수
select avg(column)
from tablename
where condition;

4. MIN

  • 가장 작은 값을 찾아주는 함수
select min(column)
from tablename
where condition;

5. MAX

  • 가장 큰 값을 찾아주는 함수
select max(column)
from tablename
where condition;

6. Group by

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

6. First

  • 첫 번째 결과값을 리턴하는 함수
select first(column)
from tablename
where condition;

7. Last

  • 마지막 결과값을 리턴하는 함수
select last(column)
from tablename
where condition;

0개의 댓글

관련 채용 정보