where절과 having절의 차이

수인·2023년 1월 1일

SQL

목록 보기
2/9

where절

  • '집계 전' 데이터를 필터링
select *
from student_score
where score >= 70

having절

  • '집계 후' 데이터를 필터링
select class_number, sum(score) as total_score
from student_score
group by 1
having sum(score) >= 340

where절에는 집계함수가 올 수 없고
having절에는 집계함수 올 수 있다.

0개의 댓글