0% found this document useful (0 votes)
33 views

Practice 1

Uploaded by

boriboboem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Practice 1

Uploaded by

boriboboem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Practice 1: Overview

In this practice, you write simple SELECT queries. The queries cover most of the SELECT clauses
and operations that you learned in this lesson.
Practice 1
Part 1
Test your knowledge:
1. The following SELECT statement executes successfully:
SELECT last_name, job_id, salary AS Sal
FROM employees;
True/False
2. The following SELECT statement executes successfully:
SELECT *
FROM job_grades;
True/False
3. There are four coding errors in the following statement. Can you identify them?
SELECT employee_id, last_name
sal x 12 ANNUAL SALARY
FROM employees;
Part 2
Note the following points before you begin with the practices:
• Save all your lab files at the following location: D:\labs\SQL1\labs
• Enter your SQL statements in a SQL Worksheet. To save a script in SQL
Developer, make sure the required SQL worksheet is active and then from
the File menu, select Save As or right-click in the SQL Worksheet and
select Save file to save your SQL statement as a
lab_<lessonno>_<stepno>.sql script. When you are modifying an existing
script, make sure you use Save As to save it with a different filename.
• To run the query, click the Execute Statement icon in the SQL Worksheet.
Alternatively, you can press [F9]. For DML and DDL statements, use the
Run Script icon or press [F5].
• After you have executed the query, make sure that you do not enter your
next query in the same worksheet. Open a new worksheet.
You have been hired as a SQL programmer for Acme Corporation. Your first task is to create
some reports based on data from the Human Resources tables.
4. Your first task is to determine the structure of the DEPARTMENTS table and its contents.
5. You need to determine the structure of the EMPLOYEES table.
The HR department wants a query to display the last name, job code, hire date, and
employee number for each employee, with the employee number appearing first. Provide an
alias STARTDATE for the HIRE_DATE column. Save your SQL statement to a file named
lab_01_05.sql so that you can dispatch this file to the HR department.
6. Test your query in the lab_01_05.sql file to ensure that it runs correctly.
Note: After you have executed the query, make sure that you do not enter your next
query in the same worksheet. Open a new worksheet.
7. The HR department wants a query to display all unique job codes from the EMPLOYEES
table.
Part 3
If you have time, complete the following exercises:
8. The HR department wants more descriptive column headings for its report on
employees. Copy the statement from lab_01_05.sql to a new SQL Worksheet. Name the column
headings Emp #, Employee, Job, and Hire Date, respectively. Then run your query again.
9. The HR department has requested a report of all employees and their job IDs. Display
the last name concatenated with the job ID (separated by a comma and space) and name the
column Employee and Title.
If you want an extra challenge, complete the following exercise:
10. To familiarize yourself with the data in the EMPLOYEES table, create a query to display all
the data from that table. Separate each column output by a comma. Name the column title
THE_OUTPUT.

You might also like