Professional Documents
Culture Documents
****************
**************************************************************************
****************
::ASSIGNMENT #3::
__________________
Course : COMP214 (Advance Database Objects)
Term: Winter 2015
Weightage: 10%
Total Marks : 20 ( Each question/part carries two marks.)
Due Date: As on DropBox
Submit in DropBox.
Dates and Grouping Functions
Student Name: ___________________
Student ID: _____________________
Section : __________
************************************************
.......
Suppose you created a table: Employees by executing following command & entered some
rows into it.
Create Table Employees
( employee_id
first_name
last_name
dept_code
hire_date
credit_limit
phone_ext
manager_id
);
Table: Employees
____________________________________________________________________________________
___________
Employee First_Name Last_Name
Dept Hire_Date
Credit
Phone Manager_id
Id
Code
Limit
Ext
____________________________________________________________________________________
___________
201
Susan
Brown
Exe
01-Jun-1998
$30.00
3484 (null)
202
Jim
Kern
Sal
16-Aug-1999 $25.00
8722 201
203
Martha
Woods
Shp
02-Feb-2004 $25.00
7591 201
204
Ellen Owens
Sal
01-Jul-2003
$15.00
6830 202
205
Henry Perkins
Sal
01-Mar-2000 $25.00
5286 202
206
Carol Rose
Act
null
null
null (null)
207
Dan
Smith
Shp
01-Dec-2004 $25.00
2259 203
208
Fred
Campbell
Shp
01-Apr-2003
$30.00
1752 203
209
Paula Jacobs
Mkt
17-Mar-1999 $15.00
3357 201
210
Nancy
Hoffman
Sal
16-Feb-2004 $25.00
2974 203
____________________________________________________________________________________
__________
Table: Departments
__________________________________
Dept Name
Location
Code
__________________________________
Act
Accounting
Toronto
Exe
Executive
Montreal
Mkt
Marketing
Vancouer
Per
Personnel
Ottawa
Sal
Sales
New York
Shp
Shipping
Chicago
_________________________________
Write Sql statements for the following tasks based on the above table.
Q1: Create a sequence - Seq-emp-id on the primary key. Start the sequence from 501 with the
increment of 10.[2 mark]
Sql Query:
Q2: Create an index on first name and last name column. [2 mark]
Sql Query:
Q3. Create a view - Emp-View from Employees table. The view should have the following
columns - employee_id, first_name, last_name, credit_limit and dept_code. It should have
employees from Sales and Marketing departments only. [2 marks]
Sql Query:
and maximum. Omit the employee having first name: Martha and last name: Woods. Store
results in table/view. [2 marks]
Q5:For each department, find the sum of the credit limits. Display all those departments, except
Executive, whose total credit limits are greater than or equal to $40.00 but less than $90.00.
Store results in table/view. [2 marks]
Q6:For each manager_id less than or equal to 202 , show the number of employees each
manager supervises. Show only those managers who manage more than 1 employee. Store
results in table/view. [2 marks]
Q7: Find how many employees have joined in the year 2004 in the Sales and Marketing
departments. Store results in table/view. [2 marks]
Q9. Write a procedure / function to return department who has got highest number of
employees..[2 marks]
Q10.Write a procedure / function to return in which month the given employee joined and in
what department name is working, and for how long..[2 marks]