Professional Documents
Culture Documents
I. Using the tables provided write a query based on the following criteria:
1. IT Support and IT Helpdesk have been merged due to cost cutting happened to the
company, which forced the company to make them one department which is IT Support.
Now the database must be change accordingly:
a. Write a query that makes the existing data of employees under IT Helpdesk be
updated to IT Support.
UPDATE Employees
SET DEPARTMENT_ID = 210
WHERE DEPARTMENT_ID = 230;
2. Due to this cost cut happened in the company several reports have been needed:
a. Write a query that will retrieve the complete name of the employee, contact number,
department name, and state province for each employee.
SELECT E.first_name,E.last_name, E.phone_number,
D.department_name, L.state_province
FROM employees E
JOIN departments D
ON E.department_id = D.department_id
JOIN locations L
ON D.location_id = L.location_id;
b. Write a query that will retrieve the complete name of the employee, Salary, that
belong to the Finance department.
SELECT first_name, last_name, salary
FROM employees
WHERE department_id = d.department_id
AND d.department_name = 'Finance';
c. Write a query that will display all the details of the employee that has a salary higher
than 12000.00.
SELECT * FROM employees
WHERE salary > 12000.00;
3. A new department named Graphics has been formed and their office has been built
in 21246 Harumi Ofuisutawaz, City of Tokyo Japan under state province of Chuo-ku
with a postal code of 1046223.
a. Write a query that will insert a new record based from number three description on
Locations table.
INSERT INTO Locations
(STREET_ADDRESS, POSTAL_CODE, CITY, STATE_PROVINCE,
COUNTRY_ID)
VALUES ('Harumi Ofuisutawaz', '1046223.', 'Tokyo', 'Japan', 'JP');
b. Since a new location is added and its Location ID is 3300 kindly write a query that will
add the Graphics department on the Departments table with the new location ID and
they are all under the supervision of Steven King.
INSERT INTO Departments
(‘DEPARTMENT_NAME’)VALUES(‘GRAPHICS)
SELECT L. LOCATION_ID
FROM Locations L
WHERE L.LOCATION_ID = 1700;
4. Random request and updates that needs to be applied in the database:
a. Write a query that will add the following details of the newly hired employee.
b. Write a query that will display all the employees who was hired from 2002 to 2006
sorted by from 2000 upwards.
SELECT * FROM Employees
WHERE HIRE_DATE BETWEEN 2000 AND 2006
ORDER BY HIRE_DATE;
d. Write a query that will display the first name, last name, department id and
department name, for all employees for departments 80 or 40.
SELECT E.first_name , E.last_name ,
E.department_id , D.department_name
FROM employees E
JOIN departments D
ON E.department_id = D.department_id
AND E.department_id IN (80 , 40)
ORDER BY E.last_name;
e. Write a query that will display the first name of all employees including the first name
of their manager.
SELECT E.first_name AS "Employee Name",
M.first_name AS "Manager"
FROM employees E
JOIN employees M
ON E.manager_id = M.employee_id;
II. Draw or write the expected output of the following queries:
4. SELECT E.FIRST_NAME,E.LAST_NAME,
D.DEPARTMENT_NAME
FROM Employees E
JOIN Departments D
ON E.DEPARTMENT_ID = D.DEPARTMENT_ID;
5. SELECT E.FIRST_NAME,E.LAST_NAME,
D.DEPARTMENT_NAME, L.CITY, L.STATE_PROVINCE
FROM Employees E
JOIN Departments D
ON E.DEPARTMENT_ID = D.DEPARTMENT_ID
JOIN Locations L
ON D.LOCATION_ID = L.LOCATION_ID;