SQL playground

SQL
A dummy HR database for people to practice SQL! Examine tables in this database then use edit the code blocks and hit run to run your query.
Author

Ran Li

Published

August 7, 2023

HR Database Information

departmentsdepartment_idINTEGERdepartment_nameSTRINGlocation_idINTEGERemployeesemployee_idINTEGERfirst_nameSTRINGlast_nameSTRINGemailSTRINGphone_numberSTRINGhire_dateSTRINGjob_idINTEGERsalaryDOUBLEmanager_idINTEGERdepartment_idINTEGERjobsjob_idINTEGERjob_titleSTRINGmin_salaryDOUBLEmax_salaryDOUBLEhashasmanages
select * from departments ;
Edit
select * from jobs  ;
Edit
select * from employees ;
Edit

SQL Queries

Examples 1, 2, 3 are example SQL queries. Feel free to edit to play around!

This query would return a result set containing the first name, last name, and salary of all employees in the employees table who meet the specified condition.

SELECT first_name, last_name, salary
FROM employees
WHERE salary > 10000;
Edit

This query retrieves the first name, last name, and salary of all employees who work in the “IT” department, ordered by salary in descending order.

SELECT e.first_name, e.last_name, e.salary
FROM employees e
JOIN departments d ON e.department_id = d.department_id
WHERE d.department_name = 'IT'
ORDER BY e.salary DESC;
Edit

This query retrieves the first name, last name, department name, and total salary of all employees, grouped by department, and includes only those departments with a total salary greater than 20,000.

SELECT d.department_name, SUM(e.salary) AS total_salary
FROM employees e
JOIN departments d ON e.department_id = d.department_id
GROUP BY d.department_name
HAVING SUM(e.salary) > 20000;
Edit