SQL Queries
SQL Queries
SQL Queries
2. Find the names of all the employees having "A" as second letter in their names.
7. Display the details of emp table in the descending order of department number.
14. Display employees working as manager in department 10 with salary between 1000 and 2000.
17. Find the highest salary ,lowest salary and avgcomm and num of employees in emp table.
20. Give promotion to all managers as senior managers if they have minimum 3 years experience
23. List out the employees whose annual salary does not exceed 50,000.
24. Show the first 4 char of employee name and last 4 char of job for all employees.
25. Show the employee details in the following format. "Mr. smith is a clerk with 2000 sal in dept 10".
28. Fetch the emp whose salary falls in the range 2000 and 5000 and whose names contain four char.
29. List out the employees whose name ends with "s".
30. Display the name, annual salary and experience of all employees who joined in the first half of 1981.
32. Modify the salary by 15% more if their experience crosses 15 years.
33. List the employee name and hiredate in descending order of hiredate.
35. List the jobs and no.of employees in each job and result should be in descending order of the number
of employees.
36. List the total salary , maximum and minimum salary and average salary of employee job wise.
37. List average salary fro all departments employing more than five people.
38. List all employees who joined the company before their managers.
39. Display the different designations in department 20 and 30 using set operator.
40. Find the jobs common to department 20 and 30 using set operator.
42. List the names of the employees drawing the highest salary.
45. List the details of the employees earning more than the highest paid manager.
46. Write a system defined primary key for the employee number column in emp table.
47. Find the jobs present in department 10 but not in department 20 using set operator.
49. Write a query to find average monthly salary of an employee based on the job and department
number.
51. Display the highest salary in each department providing that department contains minimum of 3
employees.
52. Find the total salary of all employees joined in each year.
55. Create a table EMP1 as emp then add column "number of leaves" in emp1 table and it should not
exceed 30.
56. create a table DEPT1 as dept then add a dept name, location together as UNIQUE constraint in
department table.
58. Write a query to display employee names who earn less than managers.
59. Find the employee name who earn the least salary.
61. Find the department whose average salary is greater than department 30.
68. Show the name and their manager's name for all the employees.
69. List out the employees who get salary more than the average salary of their own department.
71. Find the employees who get salary more than any of the employees of department 30 using ANY
operator.
72. Find the employees who get salary more than any of the employees of department 20 using ALL
operator.
73. Display employees working like Mr.MARTIN and getting salary atleast as Mr.JONES.
74. Show the record of highest paid employee.
75. show the department where maximum number of employees work with same job.
76. Show the employee details in the following format. "Mr. smith is a clerk with 2000 sal in dept 10".
77. Fetch the emp whose salary falls in the range 2000 and 5000 and whose names contain five
characters.
78. List out the employees whose name ends with "e".
79. Display the name, annual salary and experience of all employees who joined in the second half of
1981.
81. Modify the salary by 15% more if their experience crosses 15 years.
83. Display the empname,concatenated with the job separated by’,’ and space and name the column as
employee and title.
84. Display all the data from emp table separate each column by a ‘,’ . name the column ‘_’ outcome.
87. Display empname,deptno of all employees in dept 20 & 30 in alphabetical order by name.
88. Display the empname,hiredate of every employee who are joining in 1994.
89. Display empname and jobtitle of all employees who do not having manager.
90. To display the empname,salary and commission for all employees who earn commission sort data in
ascending order by commission.
91. Write a query to display the empname of all emp where the third letter is ‘a’.
92. Query to display the employee name of all employees who have an ‘A’ and an ‘E’ in their employee
name.
93. Display the employee name,job and salary for all employees who’s job is salesperson or clerk and
whose salary !=2500,3500,7000;
94. Display the current date label the column date.
95. Write a query for eac employee display the employee name, last name, sal, and sal increased by 15%
and expressed as a whole number label the column use salary.
96. Display the employeenames and sal of all employees order the results by deptno and then in
descending order by sal.
97. Select a row if an employee is a president or sales person and if the employee earns more than 5000.
98. Select the row if an employee is a manager and earns more than 5000 or if the employee is a
salesperson.
99. Display employeename job commission from employees who are not entirely to get a commission.
100. Display the name of all employees whose names have an ‘e’ as the second character from the
last.
101. Display the employee name hired date of all employees who join between jan-95 and dec-95.
102. Display empno, name,sal and managerid for all employees whose mgr id is 7839,7698,7566.
107. To display no.of employees in the dept 10 who can earn a comm..
108. To display the avg sal for each dept without displaying the respective deptno’s.
109. To display the avg.sal for each dept with displaying the deptno and dept no. should be
displaying in the descending order.