DB Quacks SQL Tutorial · Chapter 1

Where in the Pond is Carmen San-Duck-o?

The screen fills with dozens of names and Duckbert feels overwhelmed. Too many ducks! chuckles the turtle. Sometimes you need specific ones only. Find the young ducks aged 2 or younger for a special swimming lesson team.

Your task

Find only the ducks that are 2 years old or younger from the ducks table. You will be filtering the ducks table based on age criteria.

Hint

You need to add a condition to your query. What operator would you use to check if a value is less than or equal to another?

Expected result

A table showing only ducks aged 2 or younger.

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/4.md

Start level 4 →

DuckDB docs for this lesson