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

Exercise SQL

Uploaded by

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

Exercise SQL

Uploaded by

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

Exercise: Basic SQL

For query No 1 to 11 use Company database schema.

Query 1: Retrieve the birth date and address of the employee(s) whose name is “Ahmad V Jabbar”.

Query2: Retrieve the name and address of all employees who work for the “Administration” and
“Research” Department.

Query 3: For every project located in “Stafford”, List the project number, the controlling department
number and the department manager’s name, address, and birthdate.

Query 4: For each employee, retrieve the employee’s first and last name and the first and last name
of his or her immediate supervisor.

Query 5: Retrieve the all employee details and his department manager details.

Query 6: 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.

Query 7: Retrieve all employee whose address is in Houston, Texas.

Query 8: Find all employee who were born during the 1950s.

Query 9: Show the resulting salaries if every employee working on the ‘ProductX’ project is given a
10% raise.

Query 10: Retrieve all employee in department 5 whose salary is between $30,000 and $40,000.

Query 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.

Case Study:
Create the figure 1 database schema and specify the following queries in SQL.

a) Retrieve the names of all senior students majoring in ‘cs’ (computer science).
b) Retrieve the names of all courses taught by Professor King in 2007 and 2008.
c) For each section taught by Professor King, retrieve the course number, semester, year, and
number of students who took the section.
d) Retrieve the name and transcript of each senior student (Class = 4) majoring in CS. A transcript
includes course name, course number, credit hours, semester, year, and grade for each course
completed by the student.
e) Insert a new student, < ‘Johnson’, 25, 1, ‘Math’>, in the database.
f) Change the class of student ‘Smith’ to 2.
g) Insert a new course, < ‘Knowledge Engineering’, ‘cs4390’, 3, ‘cs’>.
h) Delete the record for the student whose name is ‘Smith’ and whose student number is 17.
Figure-1: A database that stores student and course information

You might also like