DB Quacks SQL Tutorial · Chapter 2

Duck to the Future: Temporal Mechanics

Clock-maker duck approaches surrounded by ticking clocks. Time is everything! Im the Master of Temporal Mechanics. Find all ducks born in the last 4 years using date calculations and filtering magic!

Your task

Find all ducks from the ducks table born in the last 4 years from today's date. You will be working with date filtering and the birth_date column.

Hint

You need to compare dates. Think about how to calculate "4 years ago" from the current date.

Expected result

A table showing ducks born in the last 4 years.

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[]

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

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

Start level 11 →

DuckDB docs for this lesson