분류 전체보기123 [데이터베이스설계] 3-10 from 절의 sub쿼리 from 절의 sub쿼리From 절 안의 SFW - 원래 from절에는 테이블을 줘야하는데, 그 자리에 SFW의 임시테이블 줌… 어차피 테이블이긴 함 - 이 안에 집계함수를 주면, 그 변형된 테이블에서 뽑게 됨. - 임시테이블 -> DB에 저장되지 않아서, 질의 처리 후 사라진다. Base 테이블과 다르다 - having 절을 쓸 필요가 없다 - 서브쿼리 안의 select에서 컬럼을 as로 개명해도 되고, 서브쿼리 밖에 as 테이블명(컬럼들 나열) Q)find average instructors’ salaries of those departments where average salary is greater than $42,000 .. 2025. 2. 15. [데이터베이스설계] 3-9 exist existexist [ where ] => where exists 결과 = 서브쿼리가 비어있지 않으면 true를 리턴함 = result set에 투플이 1개라도 있으면 true임 where exists r => r이 공집합이 아니라면 true where not exists r => r이 공집합이라면 true Q) find all courses_id taught in both the Fall 2017 semester and in the Spring 2018 semester=> select course_id. from section as S. where semester = “Fall” and year = 2017 and exists ( select * . .. 2025. 2. 15. [데이터베이스설계] 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. 이전 1 ··· 14 15 16 17 18 19 20 ··· 41 다음