DB Quacks SQL Tutorial · Chapter 2

Birds of a Feather GROUP Together

Goose Gordon swims up wearing a tiny campaign hat. Duckbert! Were organizing Pondvilles first Data Festival where every species gets fair representation! Professor Shellbert nods encouragingly. We need accurate species counts so every group gets a voice in planning. Can you help organize our citizen registry?

Your task

Count how many ducks of each species exist in the ducks table. You will be grouping the data by species and counting each group.

Hint

You need to organize your data into groups first, then count within each group.

Expected result

A table showing each species and the count of ducks for that species.

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

Start level 12 →

DuckDB docs for this lesson