Data-Base: Punjab University College of Information Technology
Data-Base: Punjab University College of Information Technology
DATA-BASE
Prepared for Miss. Hareem Aslam
By. Talha Mazhar Bitf19a024
TASK 1
Write a query to display the name, department number, and department name for all employees.
SELECT e.ename, d.deptno, d.dname
FROM emp e
JOIN dept d
ON (e.deptno = d.deptno)
ORDER BY e.deptno;
TASK 2
Write a query to display the employee name, department name, location of all employees who earn a
commission
SELECT e.ename, d.dname, d.loc
TASK 3
Write a query to display the name, job, department number, and department name for all employees who
work in Boston.
SELECT e.ename, e.job, e.deptno, d.dname, d.loc
FROM emp e
JOIN dept d
ON (e.deptno = d.deptno)
TASK 4
Display all employees along with their salgrade including King, who has no manager. Order the results by
the employee number.
SELECT ename, s.grade, s.losal, s.hisal
FROM emp e
ON (e.sal = s.hisal)
Task 5
Create a query that displays the name, job, department name, salary, and grade for all employees.
SELECT e.ename, e.job, d.dname, e.sal, s.grade
FROM emp e
ON e.deptno = d.deptno
ON e.sal = s.hisal
TASK 6
Find out the emps who joined in the company before their Managers.
SELECT e.ename, e.hiredate, e1.ename, e1.hiredate
Create a query that displays employee names, salary, salary increased by 40% and their salary grade acc to
increased salary. Give each column an appropriate label.
SELECT e.ename, e.sal, e.sal + (e.sal * 0.4), s.grade
AND
s.hisal
AND
s.grade = 2;
TASK 9
Create a query that displays employee names, department name of all the Employees who work in
department 10
SELECT e.ename, d.dname, d.deptno
AND
d.deptno = 10;
TASK 10
Write a query to employee Name, Job, Annual Salary, deptno, Dept name and grade who earn 36000 or
more.
SELECT e.ename, e.job, e.sal*12, d.deptno, d.dname, s.grade
AND
AND
List all the emps by name and number along with their Manager’s name and number. Also List KING who
has no ‘Manager’
SELECT e.ename, e.empno, ee.ename, e.empno
List the emps whose Mgr name is ‘Jones’ and also with his(Jones) Manager name.
SELECT e.ename, ee.ename
AND
ee.ename = 'JONES';
TASK 13
List all the employees who earn more than their managers.
SELECT e.ename, e.sal, ee.ename
AND
TASK 14
Write a query that display the salary grades of all employees that belongs to Accounting
Department.
AND
s.hisal
AND
d.dname = 'ACCOUNTING';
TASK 15
WRITE A QUERY THAT DISPLAYS ALL THE EMPLOYEES THAT HAVE SALARY GRADE OF 2 OR THEY
BELONG TO ‘BOSTON’.
SELECT *
s.hisal
AND
s.grade = 2
AND
d.loc = 'BOSTON';