w3resource logo


SQL exercises

SQL Exercises, Practice, Solution - JOINS on HR Database

Secondary Nav

SQL [27 exercises with solution]

1. Write a query in SQL to display the first name, last name, department number, and department name for each employee.  Go to the editor

Sample table : departments

Sample table : employees

Click me to see the solution

2. Write a query in SQL to display the first and last name, department, city, and state province for each employee.  Go to the editor

Sample table : departments

Sample table : employees

Sample table : locations

Click me to see the solution

3. Write a query in SQL to display the first name, last name, salary, and job grade for all employees.  Go to the editor

Sample table : employees

Sample table : job_grades

Click me to see the solution

4. Write a query in SQL to display the first name, last name, department number and department name, for all employees for departments 80 or 40.  Go to the editor

Sample table : departments

Sample table : employees

Click me to see the solution

5. Write a query in SQL to display those employees who contain a letter z to their first name and also display their last name, department, city, and state province.

Sample table : departments

Sample table : employees

Sample table : locations

Click me to see the solution

6. Write a query in SQL to display all departments including those where does not have any employee.  Go to the editor

Sample table : departments

Sample table : employees

Click me to see the solution

7. Write a query in SQL to display the first and last name and salary for those employees who earn less than the employee earn whose number is 182.  Go to the editor

Sample table : employees

Click me to see the solution

8. Write a query in SQL to display the first name of all employees including the first name of their manager.  Go to the editor

Sample table : employees

Click me to see the solution

9. Write a query in SQL to display the department name, city, and state province for each department.  Go to the editor

Sample table : departments

Sample table : locations

Click me to see the solution

10. Write a query in SQL to display the first name, last name, department number and name, for all employees who have or have not any department.  Go to the editor

Sample table : departments

Sample table : employees

Click me to see the solution

11. Write a query in SQL to display the first name of all employees and the first name of their manager including those who does not working under any manager.  Go to the editor

Sample table : employees

Click me to see the solution

12. Write a query in SQL to display the first name, last name, and department number for those employees who works in the same department as the employee who holds the last name as Taylor.  Go to the editor

Sample table : employees

Click me to see the solution

13. Write a query in SQL to display the job title, department name, full name (first and last name ) of employee, and starting date for all the jobs which started on or after 1st January, 1993 and ending with on or before 31 August, 1997.  Go to the editor

Sample table : job_history

Sample table : employees

Sample table : jobs

Click me to see the solution

14. Write a query in SQL to display job title, full name (first and last name ) of employee, and the difference between maximum salary for the job and salary of the employee.  Go to the editor

Sample table : employees

Sample table : jobs

Click me to see the solution

15. Write a query in SQL to display the name of the department, average salary and number of employees working in that department who got commission.  Go to the editor

Sample table : employees

Sample table : departments

Click me to see the solution

16. Write a query in SQL to display the full name (first and last name ) of employee, and job title of those employees who is working in the department which ID 80 and deserve a commission percentage.  Go to the editor

Sample table : employees

Sample table : jobs

Click me to see the solution

17. Write a query in SQL to display the name of the country, city, and the departments which are running there.  Go to the editor

Sample table : countries

Sample table : locations

Click me to see the solution

18. Write a query in SQL to display department name and the full name (first and last name) of the manager.  Go to the editor

Sample table : departments

Sample table : employees

Click me to see the solution

19. Write  Go to the editor

Sample table : employees

Sample table : jobs

Click me to see the solution

20. Write a query in SQL to display the details of jobs which was done by any of the employees who is presently earning a salary on and above 12000.  Go to the editor

Sample table : employees

Sample table : job_history

Click me to see the solution

21.Write a query in SQL to display the country name, city, and number of those departments where at leaste 2 employees are working. Go to the editor

Sample table : countries

Sample table : locations

Sample table : employees

Sample table : departments

Click me to see the solution

22. Write a query in SQL to display the department name, full name (first and last name) of manager, and their city.  Go to the editor

Sample table : employees

Sample table : departments

Click me to see the solution

23. Write a query in SQL to display the employee ID, job name, number of days worked in for all those jobs in department 80.  Go to the editor

Sample table : jobs

Sample table : job_history

Click me to see the solution

24. Write a query in SQL to display the full name (first and last name), and salary of those employees who working in any department located in London.  Go to the editor

Sample table : departments

Sample table : locations

Sample table : employees

Click me to see the solution

25. Write a query in SQL to display full name(first and last name), job title, starting and ending date of last jobs for those employees with worked without a commission percentage.  Go to the editor

Sample table : jobs

Sample table : job_history

Sample table : employees

Click me to see the solution

26. Write a query in SQL to display the department name and number of employees in each of the department.  Go to the editor

Sample table : departments

Sample table : employees

Click me to see the solution

27. Write a query in SQL to display the full name (firt and last name ) of employee with ID and name of the country presently where (s)he is working.  Go to the editor

Sample table : countries

Sample table : locations

Sample table : employees

Sample table : departments

Click me to see the solution

Practice Online


Go to top



Join our Question Answer community to learn and share your programming knowledge.

Help the community:

Python: Fizzbuzz

C++: Decimal to binary conversion

JavaScript: Need Help in JavaScript

Python: Help me with this program