You are on page 1of 1

Question No.

21:
Consider following two tables Employee and City:
Employee
EmployeeNo EmployeeName Manager CityCode Salary
1 Ali 4 3 4000
2 Zia 4 3 4000
3 Riaz 2 2 2000
4 Rauf 1 6000
.......

City:
CityCode CityName
1 Badin
2 Sibbi
3 Lahore
.......

Table City and Employee have one-to-many relationship and Manager field specifies the employee
number of manager e.g. Zia is Riaz’s manager:

Write SQL statements for following queries:


1. List names of all employees whose immediate boss is Rauf.
2. List names of all employees who don’t have any manager.
3. List alphabetically sorted names of all employees who live in Lahore.
4. Find total salary of all the employees who live in Lahore.
5. How many employees live in Lahore and earn more than 3000?
6. List names of all cities, where no employee lives.
7. Find total salary of all employees who don’t have any manager and their salary is below 2000.
8. List down all city names along with total number of employees belong to each city.
9. Find names of highest salaried employee for each city.
10. Find name of the city / cities, where highest number of employees live.

Question No. 22:


Define three classes: dot, line and square:
Class dot has minimum two properties i.e. x and y coordinates.
Line object is comprised of dots.
Class rectangle has minimum four properties of i.e. four dots at each corner.
Write code according to given scenario:
1. Write constructor for line with two dots and then find all dots between these two.
2. Write constructor for square with a line (given line can be at any side of square).
3. Write function named diag to find any line which diagonally connects two corners of the square.
4. Write functions named area and pdiag, function area to find area of square in number of dots
and pdiag to find same sized perpendicular line. (i.e. on line find by diag)
5. Write function named move with one parameter ‘dot’, which moves square to new location by
placing any corner of the square at given dot.

You might also like