Employee Dataset for SQL Practice
This ready-made employee dataset is designed for students to practice SQL joins. It includes 3 tables with 6,627 rows in total, covering departments, employees, and salaries. Preview rows are available for free, with the full download costing credits.
At a glance
- 3tables
- 6,627rows
- 13columns
- Jan 2010 – Dec 2023date range
The 3 tables
preview and data dictionary per tableDepartments departments · dimension table · 10 rows
Contains information about different company departments.
Preview
| department_iduuid | department_namestring | locationstring |
|---|---|---|
| ec164d08-c9b0-4262-a2cf-4b961803792b | Operations | New York |
| 51558957-4d0a-4142-a6fc-bbcd51fbb182 | Finance | New York |
| 0a778a7a-08ba-41a4-8d3b-c4595f6a35f3 | Sales | Chicago |
| e66c9bcb-72d3-4e34-81e0-43e67ffe2132 | Marketing | New York |
| ad81469b-de01-4624-a980-c2b1e05012dc | Research & Development | San Francisco |
| a9bd365f-b2cc-4847-89fd-d35be7e878d6 | Product Management | Austin |
| 585de48f-14cb-431e-904b-ed30fe5f2ef7 | Engineering | San Francisco |
| 34d43975-3a91-4b0d-8284-bb9d06875a61 | HR | Austin |
| 9477015b-c015-482d-86b8-bb08c55a4ba1 | Customer Support | Boston |
| 52b7abec-26a7-41e9-b5d4-15e7e90ec80d | Legal | New York |
Data dictionary
| column | type | description | example | null % |
|---|---|---|---|---|
department_ | uuid | Unique identifier for each department.unique | ec164d08-c9b0-4262-a2cf-4b961803792b | 0% |
department_ | string | Name of the business department.unique | Operations | 0% |
location | string | Primary office hub or operating location for the department. | New York | 0% |
Employees employees · table · 3,000 rows
Lists employee details including their position and department.
Preview
| employee_iduuid | first_namestring | last_namestring | hire_datedate | positionstring | department_iduuid |
|---|---|---|---|---|---|
| 441da94b-0d04-48c4-9bd6-cf1509d36b67 | Olivia | Smith | 2017-04-19 | Data Analyst | 585de48f-14cb-431e-904b-ed30fe5f2ef7 |
| 16c50dde-4ed0-4ff4-9ecc-99d4fe31a23f | Noah | Stewart | 2014-02-07 | Data Analyst | 51558957-4d0a-4142-a6fc-bbcd51fbb182 |
| bf3922b1-b4ef-4d0d-b6d8-1c5d04f837d5 | Emma | Scott | 2021-04-14 | Software Engineer | 51558957-4d0a-4142-a6fc-bbcd51fbb182 |
| 2a22aeab-c6be-43b7-9b3c-9db9a72635bb | Liam | Sullivan | 2010-05-03 | Software Engineer | 585de48f-14cb-431e-904b-ed30fe5f2ef7 |
| a03e696b-be93-49c6-8759-439332e383ff | Ava | Stone | 2013-05-09 | Software Engineer | 52b7abec-26a7-41e9-b5d4-15e7e90ec80d |
| b57f43e5-9b6a-4682-b81c-79d5603e9d02 | Elijah | Snyder | 2023-09-22 | Software Engineer | 0a778a7a-08ba-41a4-8d3b-c4595f6a35f3 |
| fc05f821-286e-4bca-b6a2-971d74c150fa | Olivia | Simon | 2019-06-14 | Software Engineer | 51558957-4d0a-4142-a6fc-bbcd51fbb182 |
| efb6d713-c39a-4e9f-8e53-0cc39b477763 | James | Sharp | 2019-12-18 | Software Engineer | e66c9bcb-72d3-4e34-81e0-43e67ffe2132 |
| 6a7ac9cf-6db1-4089-be26-2498e452cec7 | Isabella | Spencer | 2022-11-21 | Data Analyst | 51558957-4d0a-4142-a6fc-bbcd51fbb182 |
| f406d298-141c-4129-a449-97cc77794c03 | Benjamin | Sterling | 2016-07-29 | Software Engineer | a9bd365f-b2cc-4847-89fd-d35be7e878d6 |
Data dictionary
| column | type | description | example | null % |
|---|---|---|---|---|
employee_ | uuid | Primary key unique identifier for the employee.unique | 441da94b-0d04-48c4-9bd6-cf1509d36b67 | 0% |
first_ | string | Employee's first name, predominantly common US names. | Olivia | 0% |
last_ | string | Employee's last name or surname, predominantly common US surnames. | Smith | 0% |
hire_ | date | Date on which the employee was hired, bounded between 2010 and 2023. | 2017-04-19 | 0% |
position | string | Job title or position held by the employee. | Data Analyst | 0% |
department_ | uuid | Foreign key to departments.department_id. | 585de48f-14cb-431e-904b-ed30fe5f2ef7 | 0% |
Salaries salaries · fact table · 3,617 rows
Records salary information for employees, including effective dates.
Preview
| salary_iduuid | amountdecimal | effective_datedate | employee_iduuid |
|---|---|---|---|
| 1175d3de-3016-4493-9a5b-de05fa9e1c50 | 96078.12 | 2022-04-04 | 6a56f5cf-d453-4bdf-875b-631c3ba350cf |
| 74b30750-f7f0-4b86-b16a-792c27031726 | 112890.87 | 2020-03-16 | 30f17346-e311-47ab-970a-e4721bd6f988 |
| 108b2126-3cf3-4ae9-8395-60882d272e9e | 79312.54 | 2022-04-05 | 2c9d350c-b666-434c-9e68-0629f5cee062 |
| 632b25ae-bcf7-4758-bb8b-3ba525e603d9 | 113726.12 | 2021-05-05 | 1b91444e-b06e-4a07-9475-3190adb079ba |
| a96a3f32-c96d-43dd-a2fd-c819371072d5 | 82670.79 | 2023-06-21 | 4ccc595c-b734-43de-978c-a0fd634a2167 |
| 4d587916-9cc9-464b-9b4e-7a80e393f334 | 80229.25 | 2021-05-04 | 052c3a7a-377d-4de1-a691-c38213763a71 |
| 6a67af71-5972-4de9-b8bb-03fcf217fd25 | 100025.24 | 2017-05-17 | fbc63582-e6ab-43fc-88cd-4c72c73cfcfd |
| 15002647-140a-45be-884b-7d3c25e0b9b6 | 93240.49 | 2010-01-13 | 4de3bdd6-256f-4510-8b5c-63e7f03a4256 |
| b8871a79-7b9c-4a1c-88cd-2e9aa8822228 | 74331.51 | 2014-05-14 | 77f3ca92-b909-4acd-8f49-fb8e7c106424 |
| 3e5d58b1-2152-41d2-879f-76978c946325 | 59455.7 | 2019-08-15 | 08932d21-34d0-4208-b31e-b0b3f59cb642 |
Data dictionary
| column | type | description | example | null % |
|---|---|---|---|---|
salary_ | uuid | Unique identifier for the salary record.unique | 1175d3de-3016-4493-9a5b-de05fa9e1c50 | 0% |
amount | decimal | Annual base salary amount in USD. | 96078.12 | 0% |
effective_ | date | Date on which the specified salary amount became effective. | 2022-04-04 | 0% |
employee_ | uuid | Foreign key to employees.employee_id. | 6a56f5cf-d453-4bdf-875b-631c3ba350cf | 0% |
How the tables join
employees.department_id references departments.department_idmany to one: each Employees row points to one Departments rowsalaries.employee_id references employees.employee_idmany to one: each Salaries row points to one Employees row
Questions to answer with it
Write a SQL query to find the average salary for each department, joining employees and departments tables.
You will need to join the employees table with the departments table on department_id and then join with the salaries table on employee_id to calculate the average salary per department.
tables: employees, departments, salaries
Write a SQL query to list all employees hired in the last year, ordered by hire date.
Filter the employees table for hire_date within the last year from the current date.
tables: employees
Write a SQL query to identify employees who have not had a salary update in the last two years.
Join employees and salaries tables, then filter for employees whose latest salary effective_date is older than two years ago.
tables: employees, salaries
Find the employee with the highest salary using a window function.
Use a window function like ROW_NUMBER() or RANK() partitioned by employee and ordered by salary amount descending.
tables: employees, salaries
Starter SQL
run against this data before publishingTable names match the SQLite file and the SQL script.
Average Salary per Department
SELECT d.department_name, AVG(s.amount) AS average_salary
FROM departments d
JOIN employees e ON d.department_id = e.department_id
JOIN salaries s ON e.employee_id = s.employee_id
GROUP BY d.department_name
LIMIT 20;Employees Without Recent Salary Updates
SELECT e.employee_id, e.first_name, e.last_name, MAX(s.effective_date) AS last_salary_update
FROM employees e
LEFT JOIN salaries s ON e.employee_id = s.employee_id
GROUP BY e.employee_id, e.first_name, e.last_name
HAVING last_salary_update < date('now', '-2 years') OR last_salary_update IS NULL
LIMIT 20;Employee with Highest Salary
SELECT employee_id, first_name, last_name, amount
FROM (
SELECT
e.employee_id,
e.first_name,
e.last_name,
s.amount,
ROW_NUMBER() OVER (ORDER BY s.amount DESC) as rn
FROM employees e
JOIN salaries s ON e.employee_id = s.employee_id
) AS ranked_salaries
WHERE rn = 1
LIMIT 20;Load it with pandas
import pandas as pd
# Unzip the CSV download first: one file per table
departments = pd.read_csv("departments.csv")
employees = pd.read_csv("employees.csv")
salaries = pd.read_csv("salaries.csv")
# Join employees to departments
df = employees.merge(departments, left_on="department_id", right_on="department_id", how="left", suffixes=("", "_departments"))
print(df.groupby("department_name").size().sort_values(ascending=False))Using it in your tool
- Excel
- The dataset can be downloaded in XLSX format. Each table will be on a separate sheet.
- Power BI
- The dataset is available in multiple formats, including CSV and Excel, which can be easily imported into Power BI for visualization.
- SQL
- The dataset is provided as a SQLite database script. You can load this script into a SQLite client to practice SQL queries. The tables are 'departments', 'employees', and 'salaries'. Relationships are established via 'department_id' and 'employee_id'.
- Python
- The dataset is available in CSV and JSON formats, suitable for loading into pandas DataFrames for analysis with Python.
Formats available
- CSV (zip)One CSV file per table, zipped
- Excel workbookOne worksheet per table
- SQLite databaseA ready-to-query database file with every table
- Parquet (zip)One Parquet file per table, zipped
- SQL scriptCREATE TABLE with primary and foreign keys, then INSERTs
- CSVA single CSV file
- JSONA single JSON file
How this data was generated
Synthetic data. Every row was generated: no real people, customers or companies are in this dataset.
Synthetic data generated by GoMask DataFactory from a relational blueprint: keys, links and rules are enforced in code, text columns are filled by a language model. No real people, companies or transactions.
- The dataset was generated using GoMask DataFactory.
- Data includes synthetic employee, department, and salary information.
- Key fields are designed to facilitate SQL join practice.
- Checked by an automated quality gate: unique keys, no orphan foreign keys, required columns filled, declared rules and date ranges (realism score 100).
Limitations
- The dataset is synthetic and does not represent real-world individuals or companies.
- The number of rows in the 'salaries' table is greater than the number of employees, indicating multiple salary records per employee.
- The date range for hire and effective dates is limited to 2010-2023.
- Distributions and correlations are modelled, not measured from real records.
blueprint · employee-dataset-for-sql
Scale this dataset
Same tables. As many rows as you need.
Open the blueprint behind these 3 tables in Data Factory: keep the relationships, change a column, and generate it at the size you need.
- 200,000 rows
- 1,000,000 rows
- Tables
- departments, employees, salaries
- Licence
- yours to use, including commercially
- API slug
- employee-dataset-for-sql