UNION과 INTERSECT를 사용한 쿼리

SQL로 하는 데이터 기반 의사결정

Tim Verdonck

Professor Statistics and Data Science

UNION

SQL로 하는 데이터 기반 의사결정

예제 - UNION

SELECT title, 
       genre, 
       renting_price
FROM movies
WHERE renting_price > 2.8
UNION
SELECT title, 
       genre, 
       renting_price
FROM movies
WHERE genre = 'Action & Adventure';
SQL로 하는 데이터 기반 의사결정
SELECT title, 
       genre, 
       renting_price
FROM movies
WHERE renting_price > 2.8
UNION
SELECT title, 
       genre, 
       renting_price
FROM movies
WHERE genre = 'Action & Adventure';
| title      | genre              | renting_price |
|------------|--------------------|---------------|
|Fool's Gold | Action & Adventure | 2.69          |
|Astro Boy   | Action & Adventure | 2.89          |
|Fair Game   | Drama              | 2.89          |
SQL로 하는 데이터 기반 의사결정

INTERSECT

SQL로 하는 데이터 기반 의사결정

예제 - INTERSECT

SELECT title, 
       genre, 
       renting_price
FROM movies
WHERE renting_price > 2.8
INTERSECT
SELECT title, 
       genre, 
       renting_price
FROM movies
WHERE genre = 'Action & Adventure';
| title     | genre              | renting_price |
|-----------|--------------------|---------------|
| Astro Boy | Action & Adventure | 2.89          |
SQL로 하는 데이터 기반 의사결정

연습해 봅시다!

SQL로 하는 데이터 기반 의사결정

Preparing Video For Download...