academy.oracle.
com
Database Programming with SQL
1-3: Anatomy of a SQL Statement
Practice Activities
Objectives
• Match projection, selection, and join with their correct functions capabilities
• Create a basic SELECT statement
• Use the correct syntax to display all rows in a table
• Use the correct syntax to select specific columns in a table, modify the way data is
displayed, and perform calculations using arithmetic expressions and operators
• Formulate queries using correct operator precedence to display desired results
• Define a null value
• Demonstrate the effect null values create in arithmetic expressions
• Construct a query using a column alias
Vocabulary
Identify the vocabulary word for each definition below.
Join Display data from two or more related tables.
Arithmetic Operator A symbol used to perform an operation on some values.
Column An implementation of an attribute or relationship in a table.
Projection The capability in SQL to choose the columns in a table that you
want returned from a query.
Null A value that is unavailable, unassigned, unknown, or inapplicable.
Column Alias Renames a column heading.
Arithmetic Expression A mathematical equation.
Selection The capability in SQL to choose the rows in a table returned from
a query.
SELECT Statement Retrieves information from the database
SELECT clause Specifies the columns to be displayed
This study source was downloaded by 100000833626226 from CourseHero.com on 09-22-2022 22:56:23 GMT -05:00
https://www.coursehero.com/file/54300035/DP-1-3-Practicedocx/
FROM clause Specifies the table containing the column listed in the select
clause
Keyword An individual SQL statement
Clause Part of a SQL statement
Statement A combination of the two clauses
Try It / Solve It
Now you know the basics of a SELECT statement, It's time to practice what you've learned.
1. Write a SQL statement that demonstrates projection.
select first_name,last_name from d_clients
FIRST_NAME LAST_NAME
Hiram Peters
Serena Jones
Lauren Vigil
2. Write a query that displays the last_name and email addresses for all the people in the
DJs on Demand d_client table. The column headings should appear as “Client” and “Email
Address.”
Select last_name “Client”, email “Email Addresses” from d_clients
Client Email Address
Peters [email protected]
Jones [email protected]
Vigil [email protected]
3. The manager of Global Fast Foods decided to give all employees at 5%/hour raise + a
$.50 bonus/hour. However, when he looked at the results, he couldn't figure out why the
new raises were not as he predicted. Ms. Doe should have a new salary of $7.59, Mr.
Miller's salary should be $11.00, and Monique Tuttle should be $63.50. He used the
following query. What should he have done?
This study source was downloaded by 100000833626226 from CourseHero.com on 09-22-2022 22:56:23 GMT -05:00
https://www.coursehero.com/file/54300035/DP-1-3-Practicedocx/
SELECT last_name, salary *.05 +.50
FROM f_staffs;
Answer: select last_name,(salary *.05 ) + (salary + .50) from f_staffs
LAST_NAME (SALARY*.0
Doe 7.5875
Miller 11
Tuttle 63.5
4. Which of the following would be the easiest way to see all rows in the d_songs table?
a. SELECT id, title, duration, artist, type_code
b. SELECT columns
c. SELECT *
d. SELECT all
Answer: A
5. If tax = 8.5% * car_cost and license = car_cost * .01%, which value will produce the largest
car payment?
a. Payment = (car_cost * 1.25) + 5.00 - (tax) - (license)
b. Payment = car_cost * 1.25 + 5.00 - (tax - license)
Answer: B
3
6. In the example below, identify the keywords, the clause(s), and the statement(s):
SELECT employee_id, last_name
FROM employees
Keyword: SELECT, FROM
Clause(s): SELECT employee id, last_name ; From employees
Statement(s): SELECT employee_id, last_name
FROM employees
7. Label each example as SELECTION, PROJECTION, or JOIN.
a. Please give me Mary Adam's email address. Join
b. I will need each customer's name and the order_total for their order. Selection
c. I would like only the manager_id column, and none of the other columns. Projection
8. Which of the following statements are true?
a. null * 25 = 0;
This study source was downloaded by 100000833626226 from CourseHero.com on 09-22-2022 22:56:23 GMT -05:00
https://www.coursehero.com/file/54300035/DP-1-3-Practicedocx/
b. null * 6.00 = 6.00
c. null * .05 = null
d. (null + 1.00) + 5.00 = 5.00
Answer: C
9. How will the column headings be labeled in the following example?
SELECT bear_id bears, color AS Color, age “age” FROM
animals;
a. bears, color, age
b. BEARS, COLOR, AGE
c. BEARS, COLOR, age
d. Bears, Color, Age
Answer: C
10. Which of the following words must be in a SELECT statement in order to return all rows?
a. SELECT only
b. SELECT and FROM
c. FROM only
d. SELECT * only
Answer: D
This study source was downloaded by 100000833626226 from CourseHero.com on 09-22-2022 22:56:23 GMT -05:00
https://www.coursehero.com/file/54300035/DP-1-3-Practicedocx/
Powered by TCPDF (www.tcpdf.org)