0% found this document useful (0 votes)
56 views5 pages

Review Hands On Exercise 1 - SQL With Answers

This document provides instructions for completing hands-on exercises using sample HR data. It includes: 1) Creating sample HR database and tables 2) Loading sample data 3) Writing SQL queries to retrieve and manipulate data, including: - Selecting data from individual tables - Filtering records by country name, hire date, department, job title - Inserting a dependent record - Updating a job title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views5 pages

Review Hands On Exercise 1 - SQL With Answers

This document provides instructions for completing hands-on exercises using sample HR data. It includes: 1) Creating sample HR database and tables 2) Loading sample data 3) Writing SQL queries to retrieve and manipulate data, including: - Selecting data from individual tables - Filtering records by country name, hire date, department, job title - Inserting a dependent record - Updating a job title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Oct.

12, 2021
ISB21C – HANDS ON EXERCISE 2
A. PREPARATION

1. Download the two files attached to this assignment: Create Sample HR Database SQL
and Insert HR Data SQL.
2. In phpmyAdmin, create a new database ISB21Sample
3. On the SQL tab, copy and paste the SQL commands found under Create Sample HR
Database SQL.doc and click Go.
4. The tables should now be created inside ISB21Sample database
5. On the SQL tab again, copy and paste the SQL commands found under Insert HR Data
SQL.doc and click Go.
6. The data should now be loaded into their individual tables.
7. Perform the following actions and answer the questions found in each number.

B. TAKING ACTION.
1) Display all records per table. Write the correct SQL command used for each table.

SELECT * from countries


SELECT * FROM departments
SELECT * FROM dependents
SELECT * FROM employees
SELECT * FROM jobs
SELECT * FROM locations
SELECT * FROM regions

2) How many records are there per table?

Countries = 25
Departments = 11
Dependents = 30
Employees = 40
Jobs = 19
Locations = 7
Regions = 4

3) Display only countries (countryname) which starts with A, S, & Z. Write the correct SQL
command.
SELECT country_name FROM countries WHERE country_name like 'A%' OR
country_name LIKE 'S%' OR country_name LIKE 'Z%';

4) Insert the screenshot of the resulting contents here.

5) Display all employees whose hire date is after March 30, 1998. Follow the format shown
in the table. Write the correct SQL command.

SELECT first_name,last_name,hire_date FROM employees WHERE hire_date > '1998-


3-30';

6) Insert the screen shot of the resulting contents here.


7) What is the first record on your table?

Diana Lorentz

8) Display all employees (first name, last name, department name) who belong to the IT
department.
**To get data from more than one table, separate them with a comma ( , ).
** To specify which field are your referring to, precede the fieldname with the table
name where it belongs followed by a period (.) ex. Course.id
Write the SQL command here.

SELECT first_name, last_name, departments.department_name FROM employees,


departments where departments.department_id=employees.department_id AND
departments.department_name like 'IT'

9) Insert the screenshot of your result. What is the 3rd record on the list?
3rd record on the list: David Austin

10) Display all firstname, lastname, and job title of employees who are managers (regardless
of the department). Write the SQL command. Attach the screenshot of the results.

SELECT first_name, last_name, jobs.job_title FROM employees, jobs WHERE


employees.job_id=jobs.job_id AND jobs.job_title like '%manager'

11) Display the highest paying employee in the company. (first name, last name, salary).
Write the SQL command. Use the MAX function.
**You may nest SQL statements (SQL statement inside another SQL statement)
SELECT first_name, last_name, salary FROM employees WHERE salary = (SELECT
max(salary) FROM employees);

12) What is the result?

13) Insert your details inside the Dependents table under your chosen Employee. Write your
SQL command.
INSERT INTO command here

14) Change Purchasing Clerk to Purchasing Officer. Write the SQL command.

UPDATE jobs SET job_title = "Purchasing Officer" WHERE job_title LIKE


"PURCHASING CLERK"

15) How many rows are affected?

You might also like