Employees sample database for SQLite
A ready-to-run SQLite script with an HR table: departments, titles, hire dates, salaries and managers. Tested on SQLite 3.37.2. Updated 19 November 2026.
Employees database for SQLite
Each row is one fictional employee: department, job title, hire date, salary, office, manager and performance rating. The first eight rows are department heads; everyone else reports to a manager_id in the file.
This page has it as a SQLite script: one table and 1,000 rows, with column types chosen for SQLite, primary keys. The script drops the table if it exists, creates it and inserts the rows in one transaction, so you can run it again to reset the data. It is the same fictional data, seed 42, as on the employees dataset page, where it is also available as CSV and Excel.
We loaded this exact file into SQLite 3.37.2 and ran every question below on it; the answers shown are that output. The same questions, written for SQLite, PostgreSQL, MySQL, SQL Server and DuckDB, return the same results on all five.
Load it
Command line
sqlite3 practice.db < employees-sqlite.sql
sqlite3 practice.db ".tables"Or skip the script
Download employees.sqlite and open it in DB Browser for SQLite, DBeaver or: sqlite3 employees.sqlite
Tables and columns
employees 1,000 rows
| Column | SQLite type |
|---|---|
| employee_id | TEXT |
| first_name | TEXT |
| last_name | TEXT |
| TEXT | |
| department | TEXT |
| job_title | TEXT |
| hire_date | TEXT |
| salary | INTEGER |
| location | TEXT |
| manager_id | TEXT |
| employment_type | TEXT |
| performance_rating | INTEGER |
Practice questions
answers from SQLite 3.37.2
How many employees and what average salary does each department have?
SQL
SELECT department, COUNT(*) AS employees, ROUND(AVG(salary), 2) AS avg_salary
FROM employees
GROUP BY department
ORDER BY avg_salary DESC, department;AVG works on integers and decimals directly.
Result
| department | employees | avg_salary |
|---|---|---|
| Engineering | 231 | 118,499.13 |
| Finance | 98 | 85,516.33 |
| IT | 73 | 79,419.18 |
| Marketing | 92 | 73,951.09 |
| Sales | 157 | 71,821.02 |
| Human Resources | 54 | 70,888.89 |
| Operations | 138 | 70,050.00 |
| Customer Support | 157 | 65,672.61 |
Who are the 5 highest-paid employees?
SQL
SELECT employee_id, first_name, last_name, department, salary
FROM employees
ORDER BY salary DESC, employee_id
LIMIT 5;LIMIT n at the end returns the first n rows.
Result
| employee_id | first_name | last_name | department | salary |
|---|---|---|---|---|
| E1002 | Priya | Khan | Engineering | 222800 |
| E1482 | Wei | Kim | Engineering | 185700 |
| E1195 | James | Khan | Engineering | 184100 |
| E1875 | Karen | Martinez | Engineering | 180900 |
| E1092 | James | Young | Engineering | 179600 |
Show each of the first 8 employees (by id) next to their manager's name. (self-join)
SQL
SELECT e.employee_id, e.first_name || ' ' || e.last_name AS employee,
CASE WHEN m.employee_id IS NOT NULL THEN m.first_name || ' ' || m.last_name END AS manager
FROM employees e
LEFT JOIN employees m ON m.employee_id = e.manager_id
ORDER BY e.employee_id
LIMIT 8;|| joins strings.
Result
| employee_id | employee | manager |
|---|---|---|
| E1001 | Patricia Anderson | |
| E1002 | Priya Khan | |
| E1003 | Thomas Robinson | |
| E1004 | Kimberly Lopez | |
| E1005 | Emma Jackson | |
| E1006 | Joseph Johnson | |
| E1007 | Priya Gonzalez | |
| E1008 | Mary Moore |
How many people were hired each year since 2020?
SQL
SELECT CAST(strftime('%Y', hire_date) AS INTEGER) AS hire_year, COUNT(*) AS hires
FROM employees
WHERE CAST(strftime('%Y', hire_date) AS INTEGER) >= 2020
GROUP BY CAST(strftime('%Y', hire_date) AS INTEGER)
ORDER BY hire_year;strftime('%Y', date) returns text, so it is cast to INTEGER.
Result
| hire_year | hires |
|---|---|
| 2020 | 75 |
| 2021 | 74 |
| 2022 | 87 |
| 2023 | 77 |
| 2024 | 83 |
Who is the highest-paid person in each department? (window function)
SQL
WITH r AS (
SELECT department, employee_id, first_name, last_name, salary,
ROW_NUMBER() OVER (PARTITION BY department ORDER BY salary DESC, employee_id) AS rn
FROM employees
)
SELECT department, employee_id, first_name, last_name, salary
FROM r
WHERE rn = 1
ORDER BY department;Window functions need SQLite 3.25 or later.
Result
| department | employee_id | first_name | last_name | salary |
|---|---|---|---|---|
| Customer Support | E1007 | Priya | Gonzalez | 110700 |
| Engineering | E1002 | Priya | Khan | 222800 |
| Finance | E1004 | Kimberly | Lopez | 162000 |
| Human Resources | E1005 | Emma | Jackson | 132300 |
| IT | E1008 | Mary | Moore | 159300 |
| Marketing | E1003 | Thomas | Robinson | 141800 |
| Operations | E1006 | Joseph | Johnson | 137700 |
| Sales | E1001 | Patricia | Anderson | 132300 |
How does average salary change with performance rating?
SQL
SELECT performance_rating, COUNT(*) AS employees, ROUND(AVG(salary), 2) AS avg_salary
FROM employees
GROUP BY performance_rating
ORDER BY performance_rating;AVG works on integers and decimals directly.
Result
| performance_rating | employees | avg_salary |
|---|---|---|
| 1 | 33 | 72,330.30 |
| 2 | 131 | 88,623.66 |
| 3 | 447 | 81,907.61 |
| 4 | 278 | 82,866.55 |
| 5 | 111 | 88,200.00 |
SQLite differences used here
- AVG works on integers and decimals directly.
- || joins strings.
- LIMIT n at the end returns the first n rows.
- Window functions need SQLite 3.25 or later.
- strftime('%Y', date) returns text, so it is cast to INTEGER.