Homework Based On SQL Task#1:: Very Important Notes
Homework Based On SQL Task#1:: Very Important Notes
Task#1:
1. Create the tables in the ch07_Construction shown at the end of chapter 7 in the book
(page 282). Insert the data in the tables . You can use the SQL statement shown below to
accomplish all of that.
Very important notes:
a. You have to add the definitions of the primary keys and foreign keys to the SQL
statements.
b. You have to execute the statements to create the tables in the proper order that you have
to identify on your own.
c. You have to execute the statements to insert data in the tables in the proper order that you
have to identify on your own.
Task#2:
For each of the following queries, show the SQL statement and its output obtained using SQL
Server. You should copy the output from the SQL Server into your Microsoft Word document
that you will submit.
1. For each employee, display the employee number (emp_num), the hiring date
(emp_hireDate), total number of hours worked, and the total charges for those hours
worked.
2. For each project, display the project number (proj_num), the name (proj_name), total
number of hours worked on the project, and the total charges for those hours worked on
the project.
3. Display the total hours worked and the total charges made by all employees on all
project.
4. Display the following information about each employee: Emp_Lname, Emp_Fname, and
Job_Description
5. For each job, display the job_code and the number (i.e. how many) of employees holding
that job.
6. For each pair of projects such that the first project has a higher value than the second
project, display for each project the following information: Proj_Name, and Proj_Value.
7. Display the number of employees hired between 1/1/1992 and 1/1/2000
8. For each job, display the job_description and the number of employees holding that job
and hired between 1/1/1992 and 1/1/2000
9. Display the total number of employees and their average JOB_CHG_HOUR.
10. Display the total number of employees holding Information Technology related jobs and
their average JOB_CHG_HOUR. Information Technology related jobs are Programmer,
Systems Analyst, Database Designer, DSS Analyst, and Applications Designer.
ASSIGN_DATE datetime,
PROJ_NUM varchar(3),
EMP_NUM varchar(3),
ASSIGN_JOB varchar(3),
ASSIGN_CHG_HR float(8),
ASSIGN_HOURS float(8),
ASSIGN_CHARGE float(8)
);
INSERT INTO ASSIGNMENT VALUES('1001','3/22/2012','18','103','503','84.5','3.5','295.75');
INSERT INTO ASSIGNMENT VALUES('1002','3/22/2012','22','117','509','34.55','4.2','145.11');
INSERT INTO ASSIGNMENT VALUES('1003','3/22/2012','18','117','509','34.55','2','69.10');
INSERT INTO ASSIGNMENT VALUES('1004','3/22/2012','18','103','503','84.5','5.9','498.55');
INSERT INTO ASSIGNMENT VALUES('1005','3/22/2012','25','108','501','96.75','2.2','212.85');
INSERT INTO ASSIGNMENT VALUES('1006','3/22/2012','22','104','501','96.75','4.2','406.35');
INSERT INTO ASSIGNMENT VALUES('1007','3/22/2012','25','113','508','50.75','3.8','192.85');
INSERT INTO ASSIGNMENT VALUES('1008','3/22/2012','18','103','503','84.5','0.9','76.05');
INSERT INTO ASSIGNMENT VALUES('1009','3/23/2012','15','115','501','96.75','5.6','541.80');
INSERT INTO ASSIGNMENT VALUES('1010','3/23/2012','15','117','509','34.55','2.4','82.92');
INSERT INTO ASSIGNMENT VALUES('1011','3/23/2012','25','105','502','105','4.3','451.5');
INSERT INTO ASSIGNMENT VALUES('1012','3/23/2012','18','108','501','96.75','3.4','328.95');
INSERT INTO ASSIGNMENT VALUES('1013','3/23/2012','25','115','501','96.75','2','193.5');
INSERT INTO ASSIGNMENT VALUES('1014','3/23/2012','22','104','501','96.75','2.8','270.9');
INSERT INTO ASSIGNMENT VALUES('1015','3/23/2012','15','103','503','84.5','6.1','515.45');
INSERT INTO ASSIGNMENT VALUES('1016','3/23/2012','22','105','502','105','4.7','493.5');
INSERT INTO ASSIGNMENT VALUES('1017','3/23/2012','18','117','509','34.55','3.8','131.29');
INSERT INTO ASSIGNMENT VALUES('1018','3/23/2012','25','117','509','34.55','2.2','76.01');
INSERT INTO ASSIGNMENT VALUES('1019','3/24/2012','25','104','501','110.5','4.9','541.45');
INSERT INTO ASSIGNMENT VALUES('1020','3/24/2012','15','101','502','125','3.1','387.5');
INSERT INTO ASSIGNMENT VALUES('1021','3/24/2012','22','108','501','110.5','2.7','298.35');
INSERT INTO ASSIGNMENT VALUES('1022','3/24/2012','22','115','501','110.5','4.9','541.45');
INSERT INTO ASSIGNMENT VALUES('1023','3/24/2012','22','105','502','125','3.5','437.5');
INSERT INTO ASSIGNMENT VALUES('1024','3/24/2012','15','103','503','84.5','3.3','278.85');
INSERT INTO ASSIGNMENT VALUES('1025','3/24/2012','18','117','509','34.55','4.2','145.11');