DB Quacks SQL Tutorial · Chapter 5

UNION Jack and the Quest for Set Operations

Wizard Merlin appears in a flash! News of your festival has spread across the multiverse! Northern and Southern Duck Communities from parallel dimensions want to participate, but they have separate registries. Create a unified guest list!

Your task

Combine results from two duck populations into one unified list by working with 'data/northern_ducks.csv' and 'data/southern_ducks.csv' files. You will be merging data from two separate sources.

Hint

Look for a set operation that can combine rows from multiple SELECT statements.

Expected result

A unified list of ducks from both northern and southern populations.

Tables

duck_diaries (10 rows)

columntype
diary_idBIGINT
duck_idBIGINT
entry_dateDATE
diary_textVARCHAR
moodVARCHAR

duck_surveys (5000 rows)

columntype
survey_idBIGINT
duck_idBIGINT
ageBIGINT
favorite_foodVARCHAR
favorite_pondBIGINT
swimming_ratingBIGINT
migration_preferenceVARCHAR
social_behaviorVARCHAR
health_statusVARCHAR
activity_levelVARCHAR
survey_dateDATE
survey_locationBIGINT

ducks (15 rows)

columntype
idBIGINT
nameVARCHAR
ageBIGINT
speciesVARCHAR
birth_dateDATE
arrival_dateDATE

ponds (3 rows)

columntype
pond_idBIGINT
pond_nameVARCHAR
location_latDOUBLE
location_lngDOUBLE
capacityBIGINT
featuresVARCHAR[]
amenitiesVARCHAR[]

Files

data/northern_ducks.csv (9 rows)

columntype
nameVARCHAR
regionVARCHAR
population_idBIGINT
migration_patternVARCHAR

data/southern_ducks.csv (9 rows)

columntype
nameVARCHAR
regionVARCHAR
population_idBIGINT
migration_patternVARCHAR

Database: https://dbquacks.com/data/databases/tutorial.duckdb

This page as markdown: https://dbquacks.com/tutorial/23.md

Start level 23 →

DuckDB docs for this lesson