Mega Query
Mega Query
SELECT *
FROM EMP;
2) Display all the records in emp table where employee belongs to deptno 10?
SELECT *
FROM EMP
WHERE DEPTNO = 10;
3) Display all the records in emp table where employee does not belong to deptno 30?
SELECT *
FROM EMP
WHERE DEPTNO <> 30;
SELECT *
FROM EMP
ORDER BY SAL DESC;
7) Display all the records in emp table order by ascending deptno, descending salary?
SELECT *
FROM EMP
ORDER BY DEPTNO ASC, SAL DESC;
10) Display the records in emp table where MGR in 7698,7566 and sal should be greater then
1500
SELECT *
FROM EMP
WHERE (MGR = 7698 OR MGR = 7566) AND SAL > 1500;
12) Display all employees with how many years they have been servicing in the company?
14) Display all employees where their hiredate belongs to third quarter?
15) Display all employees where their salary is less then the Ford’s salary?
16) Display all the records in EMP table along with the rowid?
17) Display all records in EMP table those were joined before SCOTT joined?
18) Display all employees those who were joined in third quarter of 1981?
19) Add 3 months with hiredate in EMP table and display the result?
24) Display all the records in emp table where employee hired after 28-SEP-81 and before
03DEC-81?
25) Write a query that displays the employee’s names with the first letter capitalized and all other
letters lowercase for all employees whose name starts with J, A, or M
26) Display all jobs that are in department 10. Include the location of department in the output.
27) Write a query to display the employee name, department name of all employees who earn a
commission
28) Display the empno, ename, sal, and salary increased by 15%.
31) Display all the departments where employee salary greater then average salary of that
department.
32) Display all employees whose salary greater then the manager salary?
34) Display all employees where ename start with J and ends with S
35) Display all employees where employee does not belong to 10,20,40
36) Display all employees where jobs does not belong to PRESIDENT and MANAGER?
40) Display all records in emp table for employee who does not receive any commission
41) Display all ename where first character could be anything, but second character should be L?
42) Display nth highest and nth lowest salary in emp table?
44) Display emp name and corresponding subordinates. Use CONNECT BY clause.
45) Display sum of salary for each department. The output should be in one record
46) Display all department with Minimum salary and maximum salary?
47) Display all ename, sal, deptno,dname from emp, dept table where all department which has
employees as well as department does not have any employees. This query should include
non matching rows.
48) Display all ename, sal, deptno from emp, dept table where all employees which has
matching department as well as employee does not have any departments. This query
should include non matching rows.
Note: In the below query, employee will always have matching record in dept table. Emp, dept
table may not be good example to answer this question.
49) Display all ename, sal, deptno from emp, dept table where all employees which has
matching and non matching department as well as all departments in dept table which has
matching and non matching employees. This query should include non matching rows on
both the tables.
Note: In the below query, employee will always have matching record in dept table. Emp, dept
table may not be good example to answer this question.
50) Display all ename, empno, dname, loc from emp, dept table without joining two tables
51) Display all the departments where department does not have any employees
52) Display all the departments where department does have atleast one employee
54) Display ename, deptno from emp table with format of {ename} belongs to {deptno}
55) Display total number of employees hired for 1980,1981,1982. The output should be in one
record.
56) Display ename, deptno from employee table. Also add another column in the same query
and it should display ten for dept 10, twenty for dept 20, thirty for dept 30, fourty for dept
40
57) Display all the records in emp table. The ename should be lower case. The job first
character should be upper case and rest of the character in job field should be lower case.
58) Display all employees those who have joined in first week of the month ?
59) Display all empoyees those who have joined in the 49th week of the year?
60) Display empno, deptno, salary, salary difference between current record and previous
record in emp table. Deptno should be in descending order.
61) Create table emp1 and copy the emp table for deptno 10 while creating the table
62) Create table emp2 with same structure of emp table. Do not copy the data
63) Insert new record in emp1 table, Merge the emp1 table on emp table.
64) Display all the records for deptno which belongs to employee name JAMES?
65) Display all the records in emp table where salary should be less then or equal to ADAMS
salary?
66) Display all employees those were joined before employee WARD joined?
67) Display all subordinate those who are working under BLAKE?
69) Display all record in emp table for deptno which belongs to KING's Job?
70) Display the employees for empno which belongs to job PRESIDENT?
71) Display list of ename those who have joined in Year 81 as MANAGER?
73) Display who is senior most employee? How many years has been working?
77) Display ename, job, dname, deptno for each employee by using INLINE view?
78) List ename, job, sal and department of all employees whose salary is not within the salary
grade?
79) Use EMP and EMP1 table. Query should have only three columns. Display
empno,ename,sal from both tables inluding duplicates.
81) Delete all employees those are not getting any commission?
82) Delete all employees those who employeed more then 28 years
83) Add duplicate records in emp1 table. Delete the duplicate records in emp1 table.
84) Delete the employees where employee salary greater then average salary of department
salary?
86) Delete all levels of employees those who are under BLAKE?
88) Remove the department in dept table where dept does not have any employees?
92) Remove all employees who were joined before SMITH joined?
96) Increase the salary 5% for employee those who are earning commission less then 1000
98) Increase 100$ for employee who is making more then averge salary of his department?
99) Increase 1% salary for employee who is making lowest salary in dept 10
100) Reduce the commission amount from employee salary for each employee who were joined
after ALLEN joined.
101) Increase commission 10$ for employees those who are located in NEW YORK.