Practice datasets
Six relational datasets reused across every exercise and lesson example. Inspect the schema, try a sample query, then jump into practice.
6 datasets · 17 tables
Retail
Customers, products, orders and order items — the standard dataset for multi-table JOINs, revenue by category and order analysis.
Table schema
customers
| Column | Type |
|---|---|
| id | integer |
| name | text |
| text | |
| city | text |
| signup_date | date |
| segment | text |
products
| Column | Type |
|---|---|
| id | integer |
| name | text |
| category | text |
| price | numeric(12, 2) |
| stock | integer |
orders
| Column | Type |
|---|---|
| id | integer |
| customer_id | integer → customers.id |
| order_date | date |
| status | text |
order_items
| Column | Type |
|---|---|
| id | integer |
| order_id | integer → orders.id |
| product_id | integer → products.id |
| quantity | integer |
| unit_price | numeric(12, 2) |
Sample query
select c.city, count(*) as so_don
from orders o
join customers c on c.id = o.customer_id
where o.status <> 'cancelled'
group by c.city
order by so_don desc;Subscription
Subscribers, plans and payments — use it for churn, recurring revenue and renewal-rate questions.
Table schema
subscribers
| Column | Type |
|---|---|
| id | integer |
| name | text |
| signup_date | date |
| country | text |
subscriptions
| Column | Type |
|---|---|
| id | integer |
| subscriber_id | integer → subscribers.id |
| plan | text |
| started_on | date |
| ended_on | date |
| monthly_price | numeric(12, 2) |
payments
| Column | Type |
|---|---|
| id | integer |
| subscription_id | integer → subscriptions.id |
| paid_on | date |
| amount | numeric(12, 2) |
| status | text |
Sample query
select plan, count(*) as so_nguoi_dang_dung
from subscriptions
where ended_on is null
group by plan
order by so_nguoi_dang_dung desc;Banking
Branches, accounts and transactions — practise aggregating by transaction type, balances and branch activity.
Table schema
branches
| Column | Type |
|---|---|
| id | integer |
| name | text |
| city | text |
accounts
| Column | Type |
|---|---|
| id | integer |
| account_no | text |
| customer_name | text |
| branch_id | integer → branches.id |
| opened_on | date |
| balance | numeric(14, 2) |
transactions
| Column | Type |
|---|---|
| id | integer |
| account_id | integer → accounts.id |
| txn_date | date |
| type | text |
| amount | numeric(14, 2) |
Sample query
select type, sum(amount) as tong_tien
from transactions
group by type
order by tong_tien desc;HR
Departments and employees with salary, title and hire date — practise GROUP BY, AVG and comparing pay across teams.
Table schema
departments
| Column | Type |
|---|---|
| id | integer |
| name | text |
employees
| Column | Type |
|---|---|
| id | integer |
| name | text |
| department_id | integer → departments.id |
| title | text |
| salary | numeric(12, 2) |
| hire_date | date |
Sample query
select d.name as phong_ban, avg(e.salary) as luong_trung_binh
from employees e
join departments d on d.id = e.department_id
group by d.name
order by luong_trung_binh desc;Hospital
Patients and visits with fees and departments — practise counting visits, totalling fees and analysing patient groups.
Table schema
patients
| Column | Type |
|---|---|
| id | integer |
| name | text |
| dob | date |
| gender | text |
| city | text |
visits
| Column | Type |
|---|---|
| id | integer |
| patient_id | integer → patients.id |
| visit_date | date |
| department | text |
| fee | numeric(12, 2) |
Sample query
select department, count(*) as so_lan_kham, sum(fee) as tong_phi
from visits
group by department
order by tong_phi desc;Education
Students, courses and enrolments — practise completion rates, course revenue and learning-behaviour analysis.
Table schema
edu_students
| Column | Type |
|---|---|
| id | integer |
| name | text |
| signup_date | date |
| country | text |
edu_courses
| Column | Type |
|---|---|
| id | integer |
| title | text |
| price | numeric(12, 2) |
edu_enrollments
| Column | Type |
|---|---|
| id | integer |
| student_id | integer → edu_students.id |
| course_id | integer → edu_courses.id |
| enrolled_on | date |
| completed_on | date |
Sample query
select c.title, count(e.student_id) as so_hoc_vien
from edu_courses c
left join edu_enrollments e on e.course_id = c.id
group by c.title
order by so_hoc_vien desc;How the data works
- Every practice run gets its own copy of the dataset, so you can experiment freely without touching the source data.
- Data is rebuilt from the seed script before each run, so results are always consistent.
- The sample query below can be copied into the practice editor and run as-is.