[SQL] distinct 사용법!!!!

도리·2025년 2월 14일

programmers lv.2 중복제거하기

distinct 는?

  • 중복된 데이터를 제거하여 유일한 값만을 반환할 때 사용한다.

when?

  • 단일컬럼 사용
select distinct name
from table
  • 여러 컬럼 사용
select distinct name1, name2
from table

name1와 name2의 조합이 중복되지 않는 행들이 반환.

-⭐️ 집계 함수와 함께 ⭐️

select count(distinct name) as name
from table

select distinct count(name) 은 틀린코드이다.

profile
인공지능응용학과 졸업예정..

0개의 댓글