티스토리챌린지21 [데이터베이스설계] 3-8 set 멤버십 ( in / not in ) set 멤버십[in / not in]Set 멤버십 [where] => 값이 어떤 집합의 원소나 아니냐… [ in / not in ] - in = intersect- not in = except- where 부분 중 서브쿼리부분을 먼저 실행하고 그 자리를 대체하기 Q) find courses offered in Fall 2017 and in Spring 2018=> (select course_id from section where sem = ‘Fall’ and year = ‘2017’) intersect ( ~~ )=> select distinct course_id from section where semester = “Fall” and year = 2017 and .. 2024. 11. 27. [데이터베이스설계] 3-7 having절, 중첩 질의문 having절Having 절 + 조건 => group by가 있을 때, 그룹들 중 선택할 때 사용. 집계함수 많이 씀 - having 절에 집계함수 들어가는 일이 많다- group by가 있을 때, 그룹들 중 선택할 때 having 절을 사용- where 절은 그룹 형성 전에 실행되고, having 절은 그룹 구성 후에 적용됨- having 절은 select 전에 실행되어서, select에서 고르지 않은 컬럼을 조건으로 써도 됨 Q) find the names and average salaries of all departments whose average salary is greater than 42000=> select dept_name, avg(salary) as .. 2024. 11. 26. [데이터베이스설계] 3-6 집계함수, group by 집계함수집계함수 Aggregate Function => relation의 컬럼에 나타나는 값들에 대해 기능 수행 [모아서 계산]- avg = average value- min = minimum value- max = maximum value- sum = sum of values- count = number of values Q) find the average salary of instructors in the Computer Science department=> select avg(salary) //지금까지는 투플이 열거됐었음… from instructor where dept_name.. 2024. 11. 25. 이전 1 2 3 4 ··· 7 다음