Week 4 – Structured Query Langauge (SQL) Assignment
Week 4 – Structured Query Langauge (SQL) Assignment
Problem 7.1:
FROM EMPLOYEE
Problem 7.2:
-- Selecting specific columns from the PROJECT, EMPLOYEE, and JOB tables
SELECT
FROM EMPLOYEE E
ORDER BY P.PROJ_VALUE;
Problem 7.3
J.JOB_CHG_HOUR
FROM EMPLOYEE E
ORDER BY E.EMP_LNAME;
3
Problem 7.5
SELECT
-- Calculating the assignment charge by multiplying the assignment change per hour
ROUND((ASSIGN_CHG_HR * ASSIGN_HOURS), 2) AS
CALC_ASSIGN_CHARGE
FROM ASSIGNMENT
ORDER BY ASSIGN_NUM;
Problem 7.6
-- Selecting employee number, employee last name, sum of assignment hours, and sum
of assignment charge
SELECT
ROUND(SUM(A.ASSIGN_HOURS), 1) AS SUMOFASSIGN_HOURS,
ROUND(SUM(A.ASSIGN_CHARGE), 2) AS SUMOFASSIGN_CHARGE
FROM EMPLOYEE E
-- Grouping the result set by employee number and employee last name
Problem 7.7
-- Selecting project number, sum of assignment hours, and sum of assignment charge
SELECT
ROUND(SUM(A.ASSIGN_HOURS), 1) AS SUMOFASSIGN_HOURS,
ROUND(SUM(A.ASSIGN_CHARGE), 2) AS SUMOFASSIGN_CHARGE
FROM PROJECT P
GROUP BY P.PROJ_NUM;
5
Problem 8.1
-- Defining a foreign key constraint for the JOB_CODE column, referencing the JOB
);
Problem 8.2
INSERT INTO EMP_1 VALUES ('101', 'News', 'John', 'G', '2000-11-08', '502');
INSERT INTO EMP_1 VALUES ('102', 'Senior', 'David', 'H', '1989-07-12', '501');
Problem 8.5
Problem 8.6
is '500'