Experiment No 2 (AutoRecovered)
Experiment No 2 (AutoRecovered)
Objective
Program Outcome
The students will be able to retrieve zero or more rows from one or more database
tables or database views.
Problem Statement
From the COMPANY database as mentioned and described in the previous database :
1) Retrieve the birth date and address of the employee(s) whose name
is ‘John B. Smith’.
SELECT BDATE, ADDRESS FROM EMPLOYEE WHERE FNAME = ‘John’ AND MINIT = ‘B’ AND
LNAME = ‘Smith’;
2) Retrieve the name and address of all employees who work for the ‘Research’
department.
SELECT fname, lname, address FROM employee, department WHERE dname='Research' AND
dnumber=dno;
3) For every project located in ‘Stafford’, list the project number, the
controlling department number, and the department manager’s last name,
address, and birth date
SELECT pnumber, dnum, lname, address, bdate FROM project, department, employee
WHERE dnum=dnumber AND mgr_ssn=ssn AND plocation='Stafford';
7) Make a list of all project numbers for projects that involve an employee whose last
name is ‘Smith’, either as a worker or as a manager of the department that controls the
project.
(SELECT DISTINCT PNUMBER FROM PROJECT, DEPARTMENT, EMPLOYEE WHERE DNUM =
DNUMBER AND MGRSSN = SSN AND LNAME = ‘Smith’) UNION (SELECT DISTINCT PNUMBER
FROM PROJECT, WORKS_ON, EMPLOYEE WHERE PNUMBER = PNO AND ESSN = SSN AND
LNAME = ‘Smith’);
8) Retrieve all employees whose address is in Houston, Texas.
SELECT FNAME, LNAME FROM EMPLOYEE WHERE ADDRESS LIKE ‘%Houston,TX%’;
10) Show the resulting salaries if every employee working on the ‘ProductX’ project is
given a 10 percent raise.
SELECT FNAME, LNAME, 1.1*SALARY FROM EMPLOYEE, WORKS_ON, PROJECT WHERE SSN =
ESSN AND PNO = PNUMBER AND PNAME = ‘ProductX’;
11) Retrieve a list of employees and the projects they are working on, ordered by
department and, within each department, ordered alphabetically by last name, then
first name.
SELECT DNAME, LNAME, FNAME, PNAME FROM DEPARTMENT, EMPLOYEE,WORKS_ON,
PROJECT WHERE DNUMBER = DNO AND SSN = ESSN AND PNO = PNUMBER ORDER BY
DNAME DESC, LNAME ASC, FNAME ASC;