DuckDB sample databases for practice
DuckDB is an in-process analytics database: like SQLite it needs no server, but it is built for fast GROUP BY and window queries over large tables, and it reads CSV and Parquet files directly. Here are 13 practice databases as DuckDB scripts, each with six questions whose answers were produced by DuckDB 1.5.6.
Sales orders
Superstore-style retail orders with sales, cost, discount and profit.
DuckDBOnline store
Four related tables (customers, products, orders, order items) for JOIN practice.
DuckDBEmployees
An HR table: departments, titles, hire dates, salaries and managers.
DuckDBCustomers
A customer list with segments, order counts, lifetime spend and activity.
DuckDBInventory
Stock levels, reorder points and stock value across four warehouses.
DuckDBStudent grades
Test scores, averages, letter grades and attendance for grades 9-12.
DuckDBWebsite traffic
Daily sessions, users, bounce rate and conversions by channel.
DuckDBMarketing campaigns
Budget, spend, impressions, clicks, CPA and ROAS per campaign.
DuckDBCall center
Calls with queue, reason, wait and handle time, resolution and CSAT.
DuckDBRestaurant orders
Order lines with menu items, tickets, order type and payment.
DuckDBInvoices
Invoices with due dates, payment dates, tax, status and days late.
DuckDBBank transactions
One fictional account: debits, credits, categories and a running balance.
DuckDBMessy customers
A customer list with duplicates, blanks, mixed dates and text in number columns.
DuckDB SQL in these exercises
The questions are the same on every engine; what changes is the syntax. These are the DuckDB-specific parts you will meet:
- strftime(date, '%Y-%m') formats a date as year-month text (note the argument order differs from SQLite).
- year(date) returns the year as a number.
- date_diff('day', earlier, later) returns the number of days between two dates.
- LIMIT n at the end returns the first n rows.
- Yes/no columns are real BOOLEAN values.
- || joins strings.
- substr(text, start, length) cuts out part of a string.
- 1.0 * a / b gives a decimal result.
- AVG works on integers and decimals directly.
- DuckDB supports all standard window functions.
- LENGTH counts characters.
- Text comparison is case-sensitive by default.
Other engines
SQLite · PostgreSQL · MySQL · SQL Server
The data is fictional and released under CC0. AdventureWorks, Northwind and Sakila are well-known sample databases from their vendors; we do not copy them here.