0% found this document useful (0 votes)
73 views3 pages

Assignment 5

The document contains SQL queries to retrieve information from employee tables. It includes queries to display employee details with null commissions, total salaries, earnings by name, minimum and maximum salaries, details with department names ordered by hire date, salaries by department, departments with more than 4 employees, names of higher paid employees, employees in specified departments, Wong's location, deleting employees when removing a department, top 3 earners, employee-manager relationships, and highest paid employee.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views3 pages

Assignment 5

The document contains SQL queries to retrieve information from employee tables. It includes queries to display employee details with null commissions, total salaries, earnings by name, minimum and maximum salaries, details with department names ordered by hire date, salaries by department, departments with more than 4 employees, names of higher paid employees, employees in specified departments, Wong's location, deleting employees when removing a department, top 3 earners, employee-manager relationships, and highest paid employee.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

ASSIGNMENT 5

1) Display the details of the employees whose commission is NULL.


select * from emp where comm is null;

2) Display employee’s name and sal+comm. And give the heading


Total_Salary.
select ename, sal+nvl(comm,0)"total salary " from emp;

3) Display the output in following format for each Salesman:


Mr. <Employee’s name>’s total earning is (sal+comm).

select 'Mr.' ||ename|| '''s total salary is'||(sal + nvl (comm,0)) "TOTAL
EARNING " from emp;

4) Display the name and increased salary (20% increases) of each manager.
select ename , sal * 1.2 "Incresed Sal" from emp where job =
'MANAGER';

5) today’s date in following format: Today’s date is <date>.


1st May ,2021

select 'Today ''s date is '||to_char(sysdate,'ddth Month, yyyy')


"TODAY IS "from dual;

6) Display min and max salaries among all employees and rename the fields
accordingly.
select min(sal) "MINIMUM SALARY", max(sal) "MAXIMUM
SALARY" from emp;

7) Display details of all employees along with their dept name in the
ascending order of hiredate.
Select emp.*,dept.dname from emp,dept Where emp.deptno=dept.deptno
Order by hiredate;
8) Display min, max, average and total salaries of each dept in ascending
order of deptname.
select dname,min(sal),max(sal),avg(sal) from emp , dept where
emp.deptno=dept.deptno group by dname order by dname ;

9) Display name of the department and number of employees in which at


least 4 employees work on.
select dname,count(empno) from emp,dept where dept.deptno=emp.deptno
group by dname having count(empno) > =4;

10) Display emp name whose salary is higher than the average salary of
all the employees having 5 letters in their name.

select ename from emp where sal > (select avg(sal) from emp where
Length(ename) = 5);

11) Display details of all employees whose deptname is either SALES or


HRD(deptname should be supplied by user using sub query).

select * from emp where deptno in (select deptno from dept where dname
='&danme' and dname in ('HRD', 'SALES'));

12) Display name of the location where Wong is working.

select loc from dept , emp where emp.deptno=dept.deptno and emp.ename


='WONG';

13) While deleting RESEARCH department of DEPT_your name, it


automatically deletes all the corresponding employees of that dept.

14) Display the details of top 3 earners.


select * from (select * from emp order by sal desc ) where rownum <=3;

15) Display each employee’s name and their corresponding manager’s name.

SELECT A.ENAME EMPLOYEE ,B.ENAME MANAGER FROM EMP A,EMP


B WHERE A.MGR=B.EMPNO;
16) Modify 15 to include the record of King in the output.
SELECT A.ENAME EMPLOYEE ,B.ENAME MANAGER FROM EMP A,EMP
B WHERE A.MGR=B.EMPNO(+);

Display the name of the employee with max salary

select ename from emp where sal =(select max(sal) from emp);

You might also like