w3resource
w3resource logo
SQL Exercises

SQL Exercises, Practice, Solution - exercises on employee Database

SQL employee Database [115 Exercise with Solution]

[An editor is available at the bottom of the page to write and execute the scripts.]

Structure of employee Database:

employee database structure

1. Write a query in SQL to display all the information of the employees.  Go to the editor

Sample table: employees


Click me to see the solution

2. Write a query in SQL to find the salaries of all employees.  Go to the editor

Sample table: employees


Click me to see the solution

3. Write a query in SQL to display the unique designations for the employees.  Go to the editor

Sample table: employees


Click me to see the solution

4. Write a query in SQL to list the emp_name and salary is increased by 15% and expressed as no.of Dollars.  Go to the editor

Sample table: employees


Click me to see the solution

5. Write a query in SQL to produce the output of employees name and job name as a fromat of "Employee & Job".  Go to the editor

Sample table: employees


Click me to see the solution

6. Write a query in SQL to produce the output of employees as follows:   Go to the editor
Employee
JONAS(manager).

Sample table: employees


Click me to see the solution

7. Write a query in SQL to list the employees with Hire date in the format like February 22, 1991.   Go to the editor

Sample table: employees


Click me to see the solution

8. Write a query in SQL to count the no. of characters with out considering the spaces for each name.   Go to the editor

Sample table: employees


Click me to see the solution

9. Write a query in SQL to list the emp_id,salary, and commission of all the employees.   Go to the editor

Sample table: employees


Click me to see the solution

10. Write a query in SQL to display the unique department with jobs.   Go to the editor

Sample table: employees


Click me to see the solution

11. Write a query in SQL to list the employees who does not belong to department 2001.   Go to the editor

Sample table: employees


Click me to see the solution

12. Write a query in SQL to list the employees who joined before 1991.   Go to the editor

Sample table: employees


Click me to see the solution

13. Write a query in SQL to display the average salaries of all the employees who works as ANALYST.  Go to the editor

Sample table: employees


Click me to see the solution

14. Write a query in SQL to display the details of the employee BLAZE.   Go to the editor

Sample table: employees


Click me to see the solution

15. Write a query in SQL to display all the details of the employees whose commission is more than their salary.   Go to the editor

Sample table: employees


Click me to see the solution

16. Write a query in SQL to list the employees whose salary is more than 3000 after giving 25% increment.   Go to the editor

Sample table: employees


Click me to see the solution

17. Write a query in SQL to list the name of the employees, those having six characters to their name.   Go to the editor

Sample table: employees


Click me to see the solution

18. Write a query in SQL to list the employees who joined in the month January.   Go to the editor

Sample table: employees


Click me to see the solution

19. Write a query in SQL to list the name of employees and their manager separated by the string 'works for'.   Go to the editor

Sample table: employees


Click me to see the solution

20. Write a query in SQL to list all the employees whose designation is CLERK.   Go to the editor

Sample table: employees


Click me to see the solution

21. Write a query in SQL to list the employees whose experience is more than 10 years.   Go to the editor

Sample table: employees


Click me to see the solution

22. Write a query in SQL to list the employees whose salaries are less than 3500.   Go to the editor

Sample table: employees


Click me to see the solution

23. Write a query in SQL to list the name, job_name, and salary of any employee whose designation is ANALYST.   Go to the editor

Sample table: employees


Click me to see the solution

24. Write a query in SQL to list the employees who have joined in the year 1991.   Go to the editor

Sample table: employees


Click me to see the solution

25. Write a query in SQL to list the name, id, hire_date, and salary of all the employees joined before 1 apr 91.   Go to the editor

Sample table: employees


Click me to see the solution

26. Write a query in SQL to list the employee name, and job_name who are not working under a manager.   Go to the editor

Sample table: employees


Click me to see the solution

27. Write a query in SQL to list all the employees joined on 1st may 91.   Go to the editor

Sample table: employees


Click me to see the solution

28. Write a query in SQL to list the id, name, salry, and experiences of all the employees working for the manger 68319.   Go to the editor

Sample table: employees


Click me to see the solution

29. Write a query in SQL to list the id, name, salary, and experience of all the employees who earn more than 100 as daily salary.   Go to the editor

Sample table: employees


Click me to see the solution

30. Write a query in SQL to list the employees who are retiring after 31-Dec-99 after completion of 8 years of service period.   Go to the editor

Sample table: employees


Click me to see the solution

31. Write a query in SQL to list those employees whose salary is an odd value.   Go to the editor

Sample table: employees


Click me to see the solution

32. Write a query in SQL to list those employees whose salary contain only 3 digits.   Go to the editor

Sample table: employees


Click me to see the solution

33. Write a query in SQL to list the employees who joined in the month of APRIL.   Go to the editor

Sample table: employees


Click me to see the solution

34. Write a query in SQL to list the employees those who joined in company before 19th of the month.   Go to the editor

Sample table: employees


Click me to see the solution

35. Write a query in SQL to list the employees who are SALESMAN and gathered an experience over 10 years.   Go to the editor

Sample table: employees


Click me to see the solution

36. Write a query in SQL to list the employees of department id 3001 or 1001 joined in the year 1991.   Go to the editor

Sample table: employees


Click me to see the solution

37. Write a query in SQL to list the employees of department id 3001 or 1001 joined in the year 1991.   Go to the editor

Sample table: employees


Click me to see the solution

38. Write a query in SQL to list all the employees of designation CLERK in department no 2001.   Go to the editor

Sample table: employees


Click me to see the solution

39. Write a query in SQL to list the ID, name, salary, and job_name of the employees for -   Go to the editor
1. Annual salary is below 34000 but receiving some commission which should not be more than the salary,
2. And designation is SALESMAN and working for department 3001.

Sample table: employees


Click me to see the solution

40. Write a query in SQL to list the employees who are either CLERK or MANAGER.   Go to the editor

Sample table: employees


Click me to see the solution

41. Write a query in SQL to list the employees who joined in any year except the month February.   Go to the editor

Sample table: employees


Click me to see the solution

42. Write a query in SQL to list the employees who joined in the year 91.   Go to the editor

Sample table: employees


Click me to see the solution

43. Write a query in SQL to list the employees who joined in the month of June in 1991.   Go to the editor

Sample table: employees


Click me to see the solution

44. Write a query in SQL to list the employees whose annual salary is within the range 24000 and 50000.   Go to the editor

Sample table: employees


Click me to see the solution

45. Write a query in SQL to list the employees who have joined on the following dates 1st May,20th Feb, and 03rd Dec in the year 1991.   Go to the editor

Sample table: employees


Click me to see the solution

46. Write a query in SQL to list the employees working under the managers 63679,68319,66564,69000.   Go to the editor

Sample table: employees


Click me to see the solution

47. Write a query in SQL to list the employees who joined after the month JUNE in the year 1991.   Go to the editor

Sample table: employees


Click me to see the solution

48. Write a query in SQL to list the employees who joined in 90's.   Go to the editor

Sample table: employees


Click me to see the solution

49. Write a query in SQL to list the managers of department 1001 or 2001.   Go to the editor

Sample table: employees


Click me to see the solution

50. Write a query in SQL to list the employees, joined in the month FEBRUARY with a salary range between 1001 to 2000.   Go to the editor

Sample table: employees


Click me to see the solution

51. Write a query in SQL to list all the employees who joined before or after 1991.   Go to the editor

Sample table: employees


Click me to see the solution

52. Write a query in SQL to list the employees along with department name.   Go to the editor

Sample table: employees


Click me to see the solution

53. Write a query in SQL to list the name, job name, annual salary, department id, department name and grade of the employees who earn 60000 in a year or not working as an ANALYST.  Go to the editor

Sample table: employees


Click me to see the solution

54. Write a query in SQL to list the name, job name, manager id, salary, manager name, manager's salary for those employees whose salary is greater than the salary of their managers.   Go to the editor

Sample table: employees


Click me to see the solution

55. Write a query in SQL to list the employees name, department, salary and commission. For those whose salary is between 2000 and 5000 while location is PERTH.   Go to the editor

Sample table: employees


Click me to see the solution

56. Write a query in SQL to list the grade, employee name for the department id 1001 or 3001 but salary grade is not 4 while they joined the company before 1992-12-31.  Go to the editor

Sample table: employees


Click me to see the solution

57. Write a query in SQL to list the employees whose manager name is JONAS.   Go to the editor

Sample table: employees


Click me to see the solution

58. Write a query in SQL to list the name and salary of FRANK if his salary is equal to max_sal of his grade.   Go to the editor

Sample table: employees


Click me to see the solution

59. Write a query in SQL to list the employees who are working either MANAGER or ANALYST with a salary range between 2000 to 5000 without any commission.   Go to the editor

Sample table: employees


Click me to see the solution

60. Write a query in SQL to list the id, name, salary, and location of the employees working at PERTH,or MELBOURNE with an experience over 10 years.  Go to the editor

Sample table: employees


Click me to see the solution

61. Write a query in SQL to list the employees along with their location who belongs to SYDNEY, MELBOURNE with a salary range between 2000 and 5000 and joined in 1991.  Go to the editor

Sample table: employees


Click me to see the solution

62. Write a query in SQL to list the employees with their location and grade for MARKETING department who comes from MELBOURNE or PERTH within the grade 3 to 5 and experience over 5 years.  Go to the editor

Sample table: employees


Click me to see the solution

63. Write a query in SQL to list the employees who are senior to their own manager.   Go to the editor

Sample table: employees


Click me to see the solution

64. Write a query in SQL to list the employee with their grade for the grade 4.   Go to the editor

Sample table: employees


Click me to see the solution

65. Write a query in SQL to list the employees of grade 3 in department PRODUCTION or AUDIT who joined after 1991 and they are not MARKER or ADELYN to their name.  Go to the editor

Sample table: employees


Click me to see the solution

66. Write a query in SQL to list the employees in the ascending order of their salaries.   Go to the editor

Sample table: employees


Click me to see the solution

67. Write a query in SQL to list the details of the employees in ascending order to the department_id and descending order to the jobs.   Go to the editor

Sample table: employees


Click me to see the solution

68. Write a query in SQL to display all the unique job in descending order.   Go to the editor

Sample table: employees


Click me to see the solution

69. Write a query in SQL to list the id, name, monthly salary, daily salary of all the employees in the ascending order of their annual salary.   Go to the editor

Sample table: employees


Click me to see the solution

70. Write a query in SQL to list the employees in descending order who are either 'CLERK' or 'ANALYST'.   Go to the editor

Sample table: employees


Click me to see the solution

71. Write a query in SQL to display the location of CLARE.   Go to the editor

Sample table: employees


Click me to see the solution

72. Write a query in SQL to list the employees in ascending order of seniority who joined on 1-MAY-91,or 3-DEC-91, or 19-JAN-90.   Go to the editor

Sample table: employees


Click me to see the solution

73. Write a query in SQL to list the employees who are drawing the salary less than 1000 and sort the output in ascending order on salary.   Go to the editor

Sample table: employees


Click me to see the solution

74. Write a query in SQL to list the details of the employees in ascending order on the salary.   Go to the editor

Sample table: employees


Click me to see the solution

75. Write a query in SQL to list the employees in ascending order on job name and descending order on employee id.   Go to the editor

Sample table: employees


Click me to see the solution

76. Write a query in SQL to list the unique jobs of department 2001 and 3001 in descending order.   Go to the editor

Sample table: employees


Click me to see the solution

77. Write a query in SQL to list all the employees except PRESIDENT and MANAGER in ascending order of salaries.   Go to the editor

Sample table: employees


Click me to see the solution

78. Write a query in SQL to list the employees in ascending order of the salary whose annual salary is below 25000.   Go to the editor

Sample table: employees


Click me to see the solution

79. Write a query in SQL to list the employee id, name, annual salary, daily salary of all the employees in the ascending order of annual salary who works as a SALESMAN.   Go to the editor

Sample table: employees


Click me to see the solution

80. Write a query in SQL to list the employee id, name, hire_date, current date and experience of the employees in ascending order on their experiences.   Go to the editor

Sample table: employees


Click me to see the solution

81. Write a query in SQL to list the employees in ascending order of designations of those, joined after the second half of 1991.  Go to the editor

Sample table: employees


Click me to see the solution

82. Write a query in SQL to list the total information of employees table along with department, and location of all the employees working under FINANCE and AUDIT in the ascending department no.   Go to the editor

Sample table: employees


Sample table: department


Click me to see the solution

83. Write a query in SQL to display the total information of the employees along with grades in ascending order.   Go to the editor

Sample table: employees


Sample table: salary_grade


Click me to see the solution

84. Write a query in SQL to list the name, job name, department, salary, and grade of the employees according to the department in ascending order.   Go to the editor

Sample table: employees


Sample table: salary_grade


Click me to see the solution

85. Write a query in SQL to list the name, job name, salary, grade and department name of employees except CLERK and sort result set on the basis of highest salary.  Go to the editor

Sample table: employees


Sample table: department


Sample table: salary_grade


Click me to see the solution

86. Write a query in SQL to list the employee ID, name, salary, department, grade, experience, and annual salary of employees working for department 1001 or 2001.  Go to the editor

Sample table: employees


Sample table: department


Sample table: salary_grade


Click me to see the solution

87. Write a query in SQL to list the details of the employees along with the details of their departments.   Go to the editor

Sample table: employees


Sample table: department


Click me to see the solution

88. Write a query in SQL to list the employees who are senior to their own MANAGERS.   Go to the editor

Sample table: employees


Click me to see the solution

89. Write a query in SQL to list the employee id, name, salary, and department id of the employees in ascending order of salary who works in the department 1001.  Go to the editor

Sample table: employees


Click me to see the solution

90. Write a query in SQL to find the highest salary from all the employees.   Go to the editor

Sample table: employees


Click me to see the solution

91. Write a query in SQL to find the average salary and average total remuneration(salary and commission) for each type of job.   Go to the editor

Sample table: employees


Click me to see the solution

92. Write a query in SQL to find the total annual salary distributed against each job in the year 1991.   Go to the editor

Sample table: employees


Click me to see the solution

93. Write a query in SQL to list the employee id, name, department id, location of all the employees.   Go to the editor

Sample table: employees


Sample table: department


Click me to see the solution

94. Write a query in SQL to list the employee id, name, location, department of all the departments 1001 and 2001.   Go to the editor

Sample table: employees


Sample table: department


Click me to see the solution

95. Write a query in SQL to list the employee id, name, location, department of all the departments 1001 and 2001.   Go to the editor

Sample table: employees


Sample table: department


Click me to see the solution

96. Write a query in SQL to list the manager no and the number of employees working for those managers in ascending order on manager id.   Go to the editor

Sample table: employees


Click me to see the solution

97. Write a query in SQL to display the number of employee for each job in each department.   Go to the editor

Sample table: employees


Click me to see the solution

98. Write a query in SQL to list the department where at least two employees are working.   Go to the editor

Sample table: employees


Sample table: department


Click me to see the solution

99. Write a query in SQL to display the Grade, Number of employees, and maximum salary of each grade.   Go to the editor

Sample table: employees


Click me to see the solution

100. Write a query in SQL to display the department name, grade, no. of employees where at least two employees are working as a SALESMAN.   Go to the editor

Sample table: employees


Sample table: department


Sample table: salary_grade


Click me to see the solution

101. Write a query in SQL to list the no. of employees in each department where the no. is less than 4.   Go to the editor

Sample table: employees


Click me to see the solution

102. Write a query in SQL to list the name of departments where atleast 2 employees are working in that department.   Go to the editor

Sample table: employees


Sample table: department


Click me to see the solution

103. Write a query in SQL to check whether all the employees numbers are indeed unique.   Go to the editor

Sample table: employees


Click me to see the solution

104. Write a query in SQL to list the no. of employees and average salary within each department for each job name.   Go to the editor

Sample table: employees


Click me to see the solution

105. Write a query in SQL to list the names of those employees starting with 'A' and with six characters in length.   Go to the editor

Sample table: employees


Click me to see the solution

106. Write a query in SQL to list the employees whose name is six characters in length and third character must be 'R'.   Go to the editor

Sample table: employees


Click me to see the solution

107. Write a query in SQL to list the name of the employee of six characters long and starting with 'A' and ending with 'N'.   Go to the editor

Sample table: employees


Click me to see the solution

108. Write a query in SQL to list the employees who joined in the month of which second character is 'a'.   Go to the editor

Sample table: employees


Click me to see the solution

109. Write a query in SQL to list the employees whose names containing the character set 'AR' together.   Go to the editor

Sample table: employees


Click me to see the solution

110. Write a query in SQL to list the employees those who joined in 90's.   Go to the editor

Sample table: employees


Click me to see the solution

111. Write a query in SQL to list the employees whose ID not starting with digit 68.   Go to the editor

Sample table: employees


Click me to see the solution

112. Write a query in SQL to list the employees whose names containing the letter 'A'.   Go to the editor

Sample table: employees


Click me to see the solution

113. Write a query in SQL to list the employees whose name is ending with 'S' and six characters long.   Go to the editor

Sample table: employees


Click me to see the solution

114. Write a query in SQL to list the employees who joined in the month having char 'A' at any position.   Go to the editor

Sample table: employees


Click me to see the solution

115. Write a query in SQL to list the employees who joined in the month having second char is 'A'.   Go to the editor

Sample table: employees


Click me to see the solution

Practice Online


 

Structure of employee Database:

employee database structure