UNION ve INTERSECT ile sorgular

SQL ile Veri Odaklı Karar Verme

Tim Verdonck

Professor Statistics and Data Science

UNION

SQL ile Veri Odaklı Karar Verme

Örnek - 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 ile Veri Odaklı Karar Verme
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 ile Veri Odaklı Karar Verme

INTERSECT

SQL ile Veri Odaklı Karar Verme

Örnek - 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 ile Veri Odaklı Karar Verme

Hadi pratik yapalım!

SQL ile Veri Odaklı Karar Verme

Preparing Video For Download...