0% found this document useful (0 votes)
12 views

SEMF20-Assignment 2

Uploaded by

QJHV3VD3KQU3Y
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

SEMF20-Assignment 2

Uploaded by

QJHV3VD3KQU3Y
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

PUNJAB UNIVERSITY FACULTY OF COMPUTING

AND INFORMATION TECHNOLOGY (PUFCIT)

Database Systems Assignment 2

SE Morning FALL 20 Due Date: Tuesday, 2-11-2021

Instructions:
 Plagiarism will not be tolerated and will result in ZERO.
 You are supposed to do it on blank papers.
 Solve all the Queries.

o For Question 1 to 5, use these tables:

Employee (employee-name, street, city)


Works (employee-name, company-name, salary)
Company (company-name, city)
Manages (employee-name, manager-name)

1) Find the names, street address, and cities of residence for all employees who work for 'First
Bank Corporation' and earn more than $10,000.

2) Find the names of all employees in the database who live in the same cities as the
companies for which they work.

3) Assume that the companies may be located in several cities. Find all companies located in
every city in which 'Small Bank Corporation' is located.

4) Find the names of all employees who earn more than the average salary of all employees of
their company. Assume that all people work for at most one company Find the name of the
company that has the smallest payroll.

5) Find the names of all employees in the database who live in the same cities and on the same
streets as do their managers.
o For Question 6 to 21, use these tables:

EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM,


DEPTNO)
DEPT (DEPTNO, DNAME, LOC)
SALGRADE (GRADE, LOSAL, HISAL)

6) Display the ename and department number of all employees in departments 20 and 30 in
alphabetical order by ename, and length of name greater than 4.

7) Write a query that displays the employee’s names with the first letter capitalized and all
other letters lowercase and the length of the name for all employees whose name starts with
M, T, or K. Sort the results by the employees’ names.

8) For each employee, display the employee number, ename, salary, and salary increased by
15% as New Salary add a column as Increment that subtracts the old salary from the new
salary and expressed as a whole number.

9) Write a query that produces the following for each employee: earns monthly but wants.
Label the column Dream Salaries whose salary ranges in between 1100 to 2900.

10) Write a query that displays the employee names, job and hire date, also display a column
with the name ‘New Hire date’ in which increase 6 months in the hire date of the
Salesman,2 months in the hire date of Clerk ,1 month in the hired date of President. (Format
should be 31/06/ 2000.)

11) Write a query to display the employee name, hire date, number of months employed, first
Friday after hiredate and last day of the month when hired, for all employees employed for
fewer than 36 months.

12) Create a query to display the name and hire date of any employee hired after employee
SCOTT.

13) Write a query to display each department’s name, location, number of employees, and the
average salary for all employees in that department. Label the columns Name, Location,
Number of People, and Salary, respectively. Round the average salary to two decimal
places.

14) Display the manager number and the salary of the lowest paid employee for that manager.
Exclude anyone whose manager is not known. Exclude any groups where maximum salary
is less than $15,000. Sort the output in descending order of minimum salary.
15) Write a query that displays the employee numbers and last names of all employees who
work in a department with any employee whose last name contains a k, and sorted the
record on the basis of employee name.

16) Determine the number of managers without listing them. Label the column Number of
Managers.

17) Give salary of all those employees whose name is John and their location is Sydney and also
of those whose name is Smith and their location is not California.

18) Show all employee names, starting with ‘A’ and second last letter ‘M’.

19) Give employee name, hire date, department name and commission of all employees in the
format, e.g “Hanan was hired on 1-12-2001 in department Accounts with commission
2.5%” as Emp Detail, of those commission is less than 30% of the one third of their salary.

20) Give the employee numbers in ascending order as “Ascending” and in descending order as
“Descending”.

21) Show all the employee names as EMP_name of length 3 or 4.

o For Question 22 to 25, use these tables:

EMPLOYEE (NO, NAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)


DEPARTMENT (DeptNO, DeptName, LOC)
SALGRADE (GRADE, LOSAL, HISAL)

22) Give employee number, name, hire date, commission, department id, department name, location,
salary grade of all employees those names are Hassan, salary is less than 50000, commission is 2%
of the half of their salary.

23) Give names and department names of those employees whose one third salary is greater than 6000.

24) Give names of all those employees who work in the city “London”, take no commission under
manager 3323 and hire before 2002.

25) Give name, salary and LOC of all non-commissioned employees.

Teaching Assistant: Instructor:


• Junaid Alam – bcsf19a545 Farhan Ahmad Ch.

You might also like