분류 전체보기90 [데이터베이스설계] 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. [데이터베이스설계] 3-5 set 연산, null값 set 연산Set Operation => 둘이 union 호환성이 맞아야 함 = 컬럼수가 같고, 도메인이 호환(타입)되어야 함 --> union, intersect, except -> 중복 제거… 집합연산이라서 중복이 제거됨 -> 중복 허용하려면 union all, intersect all, except all( ) union ( ) => 합집합 or ( ) intersect ( ) => 교집합 and ( ) except ( ) => 차집합 but not Q) find course_id of courses that ran in Fall 2017 or in Spring 2018 => (select course_id from section where sem = ‘Fall’ and year.. 2024. 11. 24. 이전 1 ··· 4 5 6 7 8 9 10 ··· 30 다음