You are on page 1of 5

SQL Essential

T rai ni ng Assi gnments

Program Code SQL

Version 3.1

Effective Date 01/11/2020

Hanoi, 11/2020
Training Assignments SQL Issue/Revision: x/y

RECORD OF CHANGES

*A - Added M - Modified D - Deleted

Date Changes A* Contents Version


M, D

14-Oct-2016 Create A Add the new assignments. v1.0

14-Oct-2018 Update M Template. v1.1

01-Jun-2019 Update M Update Objective v1.2

1-Nov-2020 Final M Final V1.3

17e-BM/DT/FSOFT v1/1 Internal use 2/5


Training Assignments SQL Issue/Revision: x/y

Contents
For the following assignments: ........................................................................................................4
Basic Queries in SQL ......................................................................................................................4
Assignment 2_Opt1: Human Resource Management System......................................................4

17e-BM/DT/FSOFT v1/1 Internal use 3/5


Training Assignments SQL Issue/Revision: x/y

CODE: Assignment2_Opt1
TYPE: Medium
LOC: n/a
DURATION: 180 MINUTES

For the following assignments:


• Print out respectively the screenshots to show the query results.
• Pack screenshots and SQL scripts or your answers into the zip file named
Assignment2_AccountName.zip (for instance: Assignment2_NamNT.zip) then handle to the evaluator
via email (XYZ@fsoft.com.vn ) or follow the guidance of the class admin.

Basic Queries in SQL


Assignment 2_Opt1: Human Resource Management System
Barems: (1) - 20%, (2) – (10): 80%.

Objectives: H5SD - SQL skills


Problem Descriptions:
Login SQL Server and run below script to generate tables:

HR_DB_Scripts_Full.sql

Write SQL statements for following activities & print out respectively the screenshots to show test data (the
table data that you create to test each query) & query results:

1. Add at least 8 records into each created table. Note that the input data must have meaning, avoid
inputting data like ‘abc’, ‘xyz’.

2. Add job history (Job_History table) for 3 existing employees.

3. Update department name to 'ITS' for the department that has department id is 60 (Departments table).

4. Update manager id to 122 for the departments that have id is 120 and 130 (Departments table).

5. Update commission pct to 0.25 for employees (Employees table) who started working in 2008 (YEAR
(hire_date)=2008).

6. Update the min_salary to 3000 for the job with job_title 'Shipping Clerk' (Jobs table).

7. Write a query to retrieve (select) jobs for which job_title contains 'clerk' (Jobs table, using LIKE operator)

Results:

job_id job_title min_salary max_salary


PU_CLERK Purchasing Clerk 2500.00 5500.00
SH_CLERK Shipping Clerk 2500.00 5500.00
ST_CLERK Stock Clerk 2008.00 5000.00

8. Write a query to retrieve jobs where the minimum salary is from 5000 and the maximum salary from
10000.

17e-BM/DT/FSOFT v1/1 Internal use 4/5


Training Assignments SQL Issue/Revision: x/y

Results:

job_id job_title min_salary max_salary


AC_MGR Accounting Manager 8200.00 16000.00
AD_PRES President 20080.00 40000.00
AD_VP Administration Vice President 15000.00 30000.00
FI_MGR Finance Manager 8200.00 16000.00
MK_MAN Marketing Manager 9000.00 15000.00
PU_MAN Purchasing Manager 8000.00 15000.00
SA_MAN Sales Manager 10000.00 20080.00
SA_REP Sales Representative 6000.00 12008.00
AC_MGR Accounting Manager 8200.00 16000.00
AD_PRES President 20080.00 40000.00

9. Write a query to get the job history with the id 'AC_ACCOUNT'.

Results:

employee_id start_date end_date job_id department_id


101 1997-09-21 2001-10-27 AC_ACCOUNT 130
200 2002-07-01 2006-12-31 AC_ACCOUNT 190

10. Write a query to retrieve the employees (employee_id, full_name, phone_number, hire_date, job_id) who
work in the department with id 210.

Results:

employee_id full_name phone_number hire_date job_id department_id


205 Shelley Higgins 515.123.8080 2002-06-07 AC_MGR 210
206 William Gietz 515.123.8181 2002-06-07 AC_ACCOUNT 210

11. Write a query to retrieves the employees (employee_id, first_name, last_name, email) and the
employee's job (job_title).

Results:

12. Write a query to retrieves the employees (employee_id, first_name, last_name) and the employee's job
history (use JOIN between Employees, Job_History, Job, Department).

Results:

employ
first_name last_name start_date end_date job_title department_name
ee_id
101 Neena Kochhar 1997-09-21 2001-10-27 Public Accountant Corporate Tax
101 Neena Kochhar 2001-10-28 2005-03-15 Accounting Manager Corporate Tax
102 Lex De Haan 2001-01-13 2006-07-24 Programmer Treasury
114 Den Raphaely 2006-03-24 2007-12-31 Stock Clerk Shareholder Services
122 Payam Kaufling 2007-01-01 2007-12-31 Stock Clerk Shareholder Services
176 Jonathon Taylor 2006-03-24 2006-12-31 Sales Representative Construction
176 Jonathon Taylor 2007-01-01 2007-12-31 Sales Manager Construction
200 Jennifer Whalen 1995-09-17 2001-06-17 Administration Assistant Contracting
200 Jennifer Whalen 2002-07-01 2006-12-31 Public Accountant Contracting
201 Michael Hartstein 2004-02-17 2007-12-19 Marketing Representative Control And Credit

-- THE END --

17e-BM/DT/FSOFT v1/1 Internal use 5/5

You might also like