0% found this document useful (0 votes)
19 views7 pages

Experiment No 2 (AutoRecovered)

The document describes 11 SQL queries performed on a COMPANY database to retrieve employee, department and project information. The queries select data based on name, department, location, dates of birth and more. The output is ordered by department and name in the final query.

Uploaded by

Rohan Raqo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views7 pages

Experiment No 2 (AutoRecovered)

The document describes 11 SQL queries performed on a COMPANY database to retrieve employee, department and project information. The queries select data based on name, department, location, dates of birth and more. The output is ordered by department and name in the final query.

Uploaded by

Rohan Raqo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Experiment No: 2

Student Name: Rohan Yadav


Roll Number: A50105221035
Semester /Section: 3RD SEM , A
Link to Code:
Date:
Faculty Signature:
Remarks:

Objective

To familiarize with SELECT-FROM-WHERE SQL simple queries on the COMPANY


database.

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';

4) Select all combinations of EMPLOYEE Ssn and DEPARTMENT Dname in the


database.

select e.fname,e.lname,d.dname from employee e, department d


5) Retrieve all the attribute values of any EMPLOYEE who works in DEPARTMENT
number 5.
SELECT * FROM EMPLOYEE WHERE DNO = 5;
6) Retrieve all distinct salary values.
SELECT DISTINCT SALARY FROM EMPLOYEE;

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%’;

9) Find all employees who were born during the 1950s


SELECT FNAME, LNAME FROM EMPLOYEE WHERE BDATE LIKE ‘_ _ _ _ _ _ _ 70’;

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;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy