SQL Queries
SQL Queries
4. List the details of the emps in asc order of the Dptnos and desc of Jobs?
8. List the Empno, Ename, Sal, Daily sal of all emps in the asc order of Annsal.
9. List the Empno, Ename, Sal, Exp of all emps working for Mgr 7369.
10. Display all the details of the emps whose Comm. Is more than their Sal.
11. List the emps in the asc order of Designations of those joined after the second half of 1981.
12. List the emps along with their Exp and Daily Sal is more than Rs.100.
13. List the emps who are either ‘CLERK’ or ‘ANALYST’ in the Desc order.
14. List the emps who joined on 1-MAY-81,3-DEC-81,17-DEC-81,19-JAN-80 in asc order of seniority.
15. List the emp who are working for the Deptno 10 or20.
16. List the emps who are joined in the year 81.
17. List the emps who are joined in the month of Aug 1980.
18. List the emps Who Annual sal ranging from 22000 and 45000.
19. List the Enames those are having five characters in their Names.
20. List the Enames those are starting with ‘S’ and with five characters.
21. List the emps those are having four chars and third character must be ‘r’.
22. List the Five-character names starting with ‘S’ and ending with ‘H’.
24. List the emps who joined in the month of which second character is ‘a’.
25. List the emps whose Sal is four-digit number ending with Zero.
26. List the emps whose names having a character set ‘ll’ together.
28. List the emps who does not belong to Deptno 20.
29. List all the emps except ‘PRESIDENT’ & ‘MGR” in asc order of Salaries.
30. List all the emps who joined before or after 1981.
31. List the emps whose Empno not starting with digit78.
32. List the emps who joined in any year but not belongs to the month of March.
39. Find the total annual sal to distribute job wise in the year 81
41. List the department, details where at least two emps are working (****)
42. List the employees whose salary is more than 3000 after giving 20% increment.
43. List the emps name, job who are without manager.
44. List the no. of emps in each department where the no. is more than 3.
45. List the Enames who are retiring after 31-Dec-89 the max Job period is 20Y.
51. List the emps whose first 2 chars from Hiredate=last 2 characters of Salary.
52. List the emps Whose 10% of Salary is equal to year of joining.
53. List the emps those who joined in company before 15th of the month.
55. Write a query which return the day of the week for any date entered in format ‘DD-MM-YY’.
56. Count the no. of characters without considering spaces for each name.
57. Find out the emps who are getting decimal value in their Sal without using like operator.
58. Find out how may Managers are there in the company.
59. Check whether all the emps numbers are indeed unique.
60. List the emps who are drawing less than 1000 Sort the output by Salary.
EMPLOYEE
SMITH (Clerk)
ALLEN (Salesman)
63. List the No. of emp’s and Avg salary within each department for each job.
64. Find the maximum average salary drawn for each job except for ‘President’.
65. List the dept in the ascending order of the job and the desc order of the emps print empno,
ename
71. List the emps whose salaries are less than 3500.
72. List the empno,ename,sal,deptno of all the emp joined before 1 apr 81.
73. List the emp whose annual sal is <25000 in the asc order of the salaries.
74. List the empno,ename,annsal,dailysal of all the salesmen in the asc ann sal
75. List the empno,ename,hiredate,current date & exp in the ascending order of the exp.
79. List the emps who have joined on the following dates 1 may 81,17 nov 81,30 dec 81
80. List the emps who have joined in the year 1981.
81. List the emps whose annual sal ranging from 23000 to 40000.
83. List the emps who joined in the second half of 82.
85. List the emp names starting with ‘M’ with 5 chars.
86. List the emps end with ‘H’ all together 5 chars.
95. List the emp who are clerks who have exp more than 8ys.
97. List the emps joined in jan with salary ranging from 1500 to 4000.
99. List the emps along with exp of those working under the mgr whose number is starting with 7 but
100. List the emps who are working as either mgr or analyst with the salary ranging from 2000 to 5000
and
without comm.
101. List the empno,ename,sal,job of the emps with /ann sal <34000 but receiving some comm.
Which should
not be>sal and desg should be sales man working for dept 30
102. List the emps who are working for dept 10 or 20 with desgs as clerk or analyst with a sal is either 3
or
4 digits with an exp>8ys but does not belong to mons of mar,apr,sep and working for mgrs &no
is not ending
Sub Queries
Single Row
104. List the details of the emps whose Salaries more than the employee BLAKE.
108. List the emps Whose Jobs are same as MILLER or Sal is more than ALLEN.
109. List the Emps whose Sal is > the total remuneration of the SALESMAN.
110. List the employee in dept 20 whose sal is >the average sal 0f dept 10 emps.
111. List the emps whose sal is equal to the average of max and minimum
112. Find the name and Job of the emps who earn Max salary and Commission.
113. List the Deptno and their average salaries for dept with the average salary less than the averages
for all
department
116. List the emps whose job is same as either allen or sal>allen.
117. List the emps whose sal greater than blakes sal.
119. List the mgrs who are senior to king and who are junior to smith.
Multi Row
122. Display the Empno, Ename, job, Hiredate, Exp of all Mgrs
123. List the Emps of Deptno 20 whose Jobs are same as Deptno10
124. List the Emps whose Sal is same as FORD or SMITH in desc order of Sal.
126. Any jobs of deptno 10 those that are not found in deptno 20.
128. List the employees who are senior to most recently hired employee working under king.
129. List the details of the senior employee belongs to 1981.
130. List the employees who joined in 1981 with the job same as the most senior person of the year
1981.
131. List the most senior empl working under the king and grade is more than 3.
133. List the details of the department where maximum number of emps are working
135. List the emps who are not working in sales dept.
136. List the names of the emps who are getting the highest sal dept wise.
137. List the managers who are not working under the president.
138. List the name,salary,comm. For those employees whose net pay is greater than or equal to any
other
139. List the emps Whose 10% of Salary is equal to year of joining.
140. List first 50% of chars of Ename in Lower Case and remaining are upper Case.
141. List THE Name of dept where highest no. of emps are working.
142. List the emps with Hire date in format June 4, 1988.
143. Print the details of all the emps who are sub-ordinates to Blake.
144. Find all the emps who earn the minimum Salary for each job wise in ascending order.
145. Find out all the emps who earn highest salary in each job type. Sort in descending salary order.
146. List the Name, Job and Salary of the emps who are not belonging to the department 10 but who
have
147. List the Deptno, Name, Job, Salary and Sal+Comm of the SALESMAN who are earning maximum
salary and
148. List out the Name, Job, Salary of the emps in the department with the highest average salary.
149. List the details of the emps working at Chicago.
151. List the emps whose sal is same as any one of the following.
Co-Related
153. List the managers whose sal is more than his employees avg salary.
154. List the emp whose sal<his manager but more than any other manager.
156. List the emps who joined in the company on the same date.
157. Find out the Job that was filled in the first half of 1983 and same job that was filled during the same
period of 1984.
158. Find out the most recently hired emps in each Dept order by Hiredate.
159. List the employee name, Salary and Deptno for each employee who earns a salary greater than the
160. List the Deptno, Name, Job, Salary and Sal+Comm of the emps who earn the second highest
earnings
(sal + Comm.)
Joins
Equi Join
163. List the total information of EMP table along with DNAME and Loc of all the emps Working Under
an exp more than 7 years without receiving the Comm asc order of Loc.
165. List the name ,job, dname, location for those who are working as MGRS.
166. List the emps whose mgr name is jones and also list their manager name.
167. List the emp name, job, sal, grade and dname except clerks and sort on the basis of highest sal.
168. List the names of depts. Where atleast 3 are working in that department.
169. List the employee Name, Job, Annual Salary, deptno, Dept name and grade who earn 36000 a year
or who
171. List the empno, ename, sal, loc of the emps working at Chicago dallas with an exp>6ys.
172. List the emps along with loc of those who belongs to dallas ,newyork with sal ranging from 2000 to
175. List the emps with loc and grade of accounting dept or the locs dallas or Chicago with the grades 3
to
5 &exp >6y
176. List the grades 3 emps of research and operations depts.. joined after 1987 and whose names
should
177. List the empno,ename,loc,sal,dname,loc of the all the emps belonging to king dept.
Self Join
179. List the Emps who are senior to their own MGRS.
180. Display the number of employee for each job group deptno wise
181. List the manage rno and the number of employees working for those mgrs in the ascending Mgrno.
182. 87.List the emps whose sal is greater than his managers salary
183. List those Managers who are getting less than his emps Salary.
184. List the emps whose Mgr name is ‘Jones’ and also with his Manager name.
185. Find out the emps who joined in the company before their Managers.
186. List all the emps by name and number along with their Manager’s name and number. Also List KING
who
has no ‘Manager’.
187. List out the Names and Salaries of the emps along with their manager names and salaries for those
189. List the emps who are senior to their own manager
190. Display the total information of the emps along with Grades in the asc order.
193. Display the Grade, Number of emps, and max sal of each grade.
194. List the name and salary of ford if his salary is equal to hisal of his grade.
195. List the emps whose salgrade are greater than the grade of miller.
Outer Join
196. List the details of the Depts along with Empno, Ename or without the emps
Mixed Queries
197. Display the Empno, Ename, Sal, Dname, Loc, Deptno, Job of all emps working at CJICAGO or
working for
ACCOUNTING dept with Ann Sal>28000, but the Sal should not be=3000 or 2800 who doesn’t belongs
to the
Mgr and whose no is having a digit ‘7’ or ‘8’ in 3rd position in the asc order of Deptno and desc order of
job.
198. List the Empno, Ename, Sal, Dname, Grade, Exp, and Ann Sal of emps working for Dept10 or20.
199. List all the information of emp with Loc and the Grade of all the emps belong to the Grade range
from
2 to 4 working at the Dept those are not starting with char set ‘OP’ and not ending with ‘S’ with the
designation having a char ‘a’ any where joined in the year 1981 but not in the month of Mar or Sep and
Sal
200. List the emps who are senior to BLAKE working at CHICAGO & BOSTON.
201. List the Emps of Grade 3,4 belongs to the dept ACCOUNTING and RESEARCH whose Sal is more than
ALLEN
203. List the most recently hired emp of grade3 belongs to location CHICAGO.
204. Display dname, grade, No. of emps where at least two emps are clerks.
205. List the emps name ,dept, sal and comm. For those whose salary is between 2000 and 5000 while
loc is
Chicago.
206. List the grade, EMP name for the deptno 10 or deptno 30 but sal grade is not 4 while they joined
the
207. Lit the name, job, dname ,sal, grade dept wise
208. List the managers whose sal is more than his employess avg salary.
209. List the name of the dept where more than average no. of emps are working.
210. List the Managers name who is having max no.of emps working under him.