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.
HR Database Information
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;
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;
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;