Vous êtes sur la page 1sur 4

D A T A B A S E

SPRING ASSIGNMENT
Submission Date and Time: 22-APRIL-2019 / 11:59 pm
- No assignment will be received after the due date.
(This is ASSIGNMENT for Lab so those students who are enrolled in just subject are not supposed
to do this assignment)

Total Marks: 150

SUBMISSION CRITERIA
1. Make a word file and name it as BSEF17M5**
2. Copy/Paste the question of query with proper question number
3. Copy/Paste the answer of that query.
4. Attach the screenshot of that particular query.
5. Finally email your WORD file at bitf16a519@pucit.edu.pk
6. All done 

1. For the following relation schema:

Employee (employee-name, street, city)


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

NOTE:
Create these tables on your ORACLE DESKTOP and add 10 rows in them. The data in the
rows will be of your own choice. The column name and table name should be same as given.

Give an expression in SQL for each of the following queries:

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

b) Find the names of all employees in the database who live in the same cities as the

FARHAN-CH,PUCIT-NC 1
companies for which they work.

c) Find the names of all employees in the database who live in the same cities and on the
same streets as do their managers.

d) Find the names of all employees in the database who do not work for 'First Bank
Corporation'. Assume that all people work for exactly one company.

e) Find the names of all employees in the database who earn more than every employee
of 'Small Bank Corporation'. Assume that all people work for at most one company.

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

g) 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.

h) Find the name of the company that has the smallest payroll.
2. For the following relation schema:

Customers (customer-id,first-name,last-name,birth-date,join-date,city,state,street,main-
phone-no,secondary-phn-num,fax,monthly-discount,pack-id)
Pack-grades(grade-id,grade-name,min-price,max-price)
packages(pack-id,speed,strt-date,monthly-payment,sector-id)
sectors(sector-id,sector-name)

NOTE:
Create these tables on your ORACLE DESKTOP and add 10 rows in them. The data in the
rows will be of your own choice. The column name and table name should be same as given.

Give an expression in SQL for each of the following queries:

1. Display the customer number, first name in lowercase and last name in uppercase for all
customers whose customer number is in the range of 80 and 150.

2. Generating Email Addresses


a. For all customers – display the last name, first name and email address. The email
address will be composed from the first letter of first name concatenated with
three first letters of last name concatenated with the string “@mymail.com” (For
example : Ram Kedem → RKED@mymail.com).

FARHAN-CH,PUCIT-NC 2
b. For all customers – display the last name, first name and email address. The email
address will be composed from the first letter of first name concatenated with
three last letters of last name concatenated with the string “@mymail.com” (For example
: Ram Kedem → RDEM@mymail.com).

3. Display the last name and the length of the last name for all customers where last name’s
length is greater than 9 characters.

4. Display the lowest last name alphabetically (Customers table).

5. Display the average monthly payment (Packages table).

6. Display the highest last name alphabetically (Customers table).

7. Display the first name, last name, city and state for all customers who live in the same state
as customer number 170 (Customers table).

8. Display the package number, internet speed and sector number for all packages whose sector
number equals to the sector number of package number 10 (Packages table).

9. Display the first name, last name and join date for all customers who joined the company
after customer number 540 (Customers table).

10. Customers and internet packages (Customers & Packages tables) –

a. Write a query to display first name, last name, package number and internet
speed for all customers.

b. Write a query to display first name, last name, package number and internet
speed for all customers whose package number equals 22 or 27. Order the
query in ascending order by last name.

11. Internet packages and sectors –


a. Display the package number, internet speed, monthly payment and sector name
for all packages (Packages and Sectors tables).
b. Display the customer name, package number, internet speed, monthly payment
and sector name for all customers (Customers, Packages and Sectors tables).
c. Display the customer name, package number, internet speed, monthly payment
and sector name for all customers in the business
sector (Customers, Packages and Sectors tables).

FARHAN-CH,PUCIT-NC 3
12. Display the last name, first name, join date, package number, internet speed and sector
name for all customers in the private sector who joined the company in the year 2006.

 ALL THE BEST 

FARHAN-CH,PUCIT-NC 4

Vous aimerez peut-être aussi