Section 6 Quiz

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 32
At a glance
Powered by AI
The key takeaways are about different types of joins (inner, left outer, right outer, etc.), hierarchical queries using recursive relationships, and correlated and non-correlated subqueries.

The different types of joins are inner join, left outer join, right outer join, full outer join, cross join.

A left outer join returns all rows from the left table and matched rows from the right table. A left join returns only the matched rows from both tables.

Section 6 Quiz

(Answer all questions in this section)


1.You need to join the EMPLOYEE_HIST and EMPLOYEES tables.
The EMPLOYEE_HIST table will be the first table in the FROM
clause. All the matched and unmatched rows in the EMPLOYEES
table need to be displayed. Which type of join will you use?

Mark for Review


(1) Points

A left outer join


An inner join
A cross join
A right outer join (*)
Correct
2.Which query represents the correct syntax for a left outer join?

Mark for Review


(1) Points

SELECT companyname, orderdate, total


FROM customers c
LEFT JOIN orders o
ON c.cust_id = o.cust_id;
SELECT companyname, orderdate, total
FROM customers c
OUTER JOIN orders o
ON c.cust_id = o.cust_id;
SELECT companyname, orderdate, total
FROM customers c
LEFT OUTER JOIN orders o
ON c.cust_id = o.cust_id;
(*)
SELECT companyname, orderdate, total
FROM customers c
LEFT OUTER orders o
ON c.cust_id = o.cust_id;
Correct
3.For which of the following tables will all the values be retrieved even
if there is no match in the other?

Mark for Review


(1) Points

SELECT e.last_name, e.department_id, d.department_name


FROM employees e
LEFT OUTER JOIN departments d
ON (e.department_id = d.department_id);
employees (*)
department
Neither. The LEFT OUTER JOIN limits the value to the matching
department ids.
Both
Correct
4.EMPLOYEES Table:
Name
EMPLOYEE_ID

Mark for Review


Null?
NOT NULL

FIRST_NAME

Type
NUMBER(6)
VARCHAR2(20)

LAST_NAME

NOT NULL

DEPARTMENT_ID

VARCHAR2(25)
NUMBER (4)

DEPARTMENTS Table:
Name

Null?

Type

DEPARTMENT_ID

NOT NULL

NUMBER 4

DEPARTMENT_NAME

NOT NULL

VARCHAR2(30)

MANAGER_ID

NUMBER (6)

A query is needed to display each department and its manager name


from the above tables. However, not all departments have a manager
but we want departments returned in all cases. Which of the following
SQL: 1999 syntax scripts will accomplish the task?
SELECT d.department_id, e.first_name, e.last_name
FROM employees e, departments d
WHERE e.employee_id
RIGHT OUTER JOIN d.manager_id;
SELECT d.department_id, e.first_name, e.last_name
FROM employees e
FULL OUTER JOIN departments d
ON (e.employee_id = d.manager_id);

(1) Points

SELECT d.department_id, e.first_name, e.last_name


FROM employees e
LEFT OUTER JOIN departments d
WHERE (e.department_id = d.department_id);
SELECT d.department_id, e.first_name, e.last_name
FROM employees e
RIGHT OUTER JOIN departments d
ON (e.employee_id = d.manager_id);
(*)
Correct
5.Which of the following database design concepts do you need in your
tables to write Hierarchical queries?

Mark for Review


(1) Points

Non-Transferability
Arc
Recursive Relationship (*)
Supertype
Correct
Section 6 Quiz
(Answer all questions in this section)
6. Which of the following database design concepts is implemented
with a self join?

Mark for Review


(1) Points

Non-Transferability
Supertype
Arc
Recursive Relationship (*)
Incorrect. Refer to Section 6 Lesson 4.
7. Hierarchical queries can walk both Top-Down and Bottom-Up. True
or False?

Mark for Review


(1) Points

True (*)

False
Correct
8. Which statement about a self join is true?

Mark for Review


(1) Points

Table aliases cannot be used to qualify table names.


The NATURAL JOIN clause must be used.
Table aliases must be used to qualify table names. (*)
A self join must be implemented by defining a view.
Correct
9. Evaluate this SELECT statement:
SELECT *
FROM employee e, employee m
WHERE e.mgr_id = m.emp_id;
Which type of join is created by this SELECT statement?

Mark for Review


(1) Points

a full outer join


a self join (*)
a left outer join
a cross join
Correct
10.The ___________ join is the ANSI-standard syntax used to generate
a Cartesian product.

Mark for Review


(1) Points

ALL
CROSS (*)
NATURAL
FULL
Correct
Section 6 Quiz
(Answer all questions in this section)

11.The join column must be included in the select statement when you
use the NATURAL JOIN clause. True or False?

Mark for Review


(1) Points

True
False (*)
Correct
12.What happens when you create a Cartesian product?

Mark for Review


(1) Points

No rows are returned as you entered wrong join-criteria.


Each row from one table is joined to all the rows of another
table. (*)
The table is joined to itself, one column to the next column,
exhausting all possibilities.
All rows that do not match in the WHERE clause are displayed.
Correct
13.For which condition would you use an equijoin query with the
USING keyword?

Mark for Review


(1) Points

The CUSTOMER and ORDER tables have no columns with


identical names.
You need to perform a join of the CUSTOMER and ORDER
tables but limit the number of columns in the join condition. (*)
The ORDER table contains a column that has a referential
constraint to a column in the PRODUCT table.
The CUSTOMER and ORDER tables have a corresponding
column, CUST_ID. The CUST_ID column in the ORDER table
contains null values that need to be displayed.
Correct
14.The keywords JOIN _____________ should be used to join tables
with the same column names but different datatypes.

Mark for Review


(1) Points

NATURAL ON
ON

WHEN
USING (*)
Correct
15.Below find the structures of the PRODUCTS and VENDORS tables:
PRODUCTS
PRODUCT_ID NUMBER
PRODUCT_NAME VARCHAR2 (25)
VENDOR_ID NUMBER
CATEGORY_ID NUMBER
VENDORS
VENDOR_ID NUMBER
VENDOR_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
You want to create a query that will return an alphabetical list of
products, including the product name and associated vendor name,
for all products that have a vendor assigned.
Which two queries could you use?
(Choose all correct answers)
SELECT p.product_name, v.vendor_name
FROM products p
NATURAL JOIN vendors v
ORDER BY p.product_name;
(*)
SELECT p.product_name, v.vendor_name
FROM products p
LEFT OUTER JOIN vendors v
ON p.vendor_id = v.vendor_id
ORDER BY p.product_name;
SELECT p.product_name, v.vendor_name
FROM products p
JOIN vendors v
USING (vendor_id)

Mark for Review


(1) Points

ORDER BY p.product_name;
(*)
SELECT p.product_name, v.vendor_name
FROM products p
JOIN vendors v
ON (vendor_id)
ORDER BY p.product_name;
SELECT p.product_name, v.vendor_name
FROM products p
JOIN vendors v
USING (p.vendor_id)
ORDER BY p.product_name;
Incorrect. Refer to Section 6 Lesson 2.
Section 7 Quiz
(Answer all questions in this section)
1.Using Oracle Proprietary join syntax, which operator would you use
after one of the column names in the WHERE clause when creating an
outer join?

Mark for Review


(1) Points

+
*
(+) (*)
=
Correct
2.Using Oracle Proprietary join syntax, which two operators can be used
in an outer join condition using the outer join operator (+)?

Mark for Review


(1) Points

IN and =
AND and = (*)
OR and =
BETWEEN...AND... and IN
Correct
3.Nonequijoins are normally used with which of the following? (Choose
two)

Mark for Review


(1) Points

(Choose all correct answers)


ranges of columns
Ranges of text
Ranges of numbers (*)
Ranges of rowids
Ranges of dates (*)
Correct
4.Which operator is typically used in a nonequijoin?

Mark for Review


(1) Points

OR
*
>=, <=, or BETWEEN ...AND (*)
NOT
IN
Correct
5.The following is a valid outer join statement:
SELECT c.country_name, d.department_name
FROM countries c, departments d
WHERE c.country_id (+) = d.country_id (+)
True or False?
True
False (*)
Correct
Page 1 of 3

Mark for Review


(1) Points

Section 7 Quiz
(Answer all questions in this section)

6. To perform a valid outer join between DEPARMENTS and EMPLOYE


SELECT d.department_name, e.last_name
FROM employees e, departments d
WHERE
e.department_id = d.department_id

e.department_id(+) = d.department_id (*)


e.department_id = d.department_id(+)
e.department_id(+) = d.department_id(+)
Correct
7. Which of the following best describes the function of an outer join?

An outer join will return only those rows t

An outer join will return only data from th


An outer join will return data only if both

An outer join will return all rows that mee


Correct
8. You have the following EMPLOYEES table:
EMPLOYEE_ID NUMBER(5) NOT NULL PRIMARY KEY
FIRST_NAME VARCHAR2(25)
LAST_NAME VARCHAR2(25)
ADDRESS VARCHAR2(35)
CITY VARCHAR2(25)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
DEPARTMENT_ID NUMBER(5) NOT NULL FOREIGN KEY
The BONUS table includes the following columns:

BONUS_ID NUMBER(5) NOT NULL PRIMARY KEY


ANNUAL_SALARY NUMBER(10)
BONUS_PCT NUMBER(3, 2)
EMPLOYEE_ID VARCHAR2(5) NOT NULL FOREIGN KEY

You want to determine the amount of each employee's bonus as a calcul

SELECT e.first_name, e.last_name, b.ann


FROM employees, bonus
WHERE e.employee_id = b.employee_id;
SELECT e.first_name, e.last_name, b.ann
FROM employees e, bonus b
WHERE e.employee_id = b.employee_id;
SELECT first_name, last_name, annual_s
FROM employees, bonus NATURAL JOI
SELECT e.first_name, e.last_name, b.ann
FROM employees e, bonus b
WHERE e.employee_id = b.employee_id;
(*)
Correct

9. Which statement about the join syntax of an Oracle Proprietary join syn

The FROM clause represents the join crite


The JOIN keyword must be included.

The WHERE clause represents the join cri


The ON keyword must be included.
Correct
10. When must column names be prefixed by table names in join syntax?

When the same column name appears in m

Only when query speed and database perf

When the more than two tables participate

Never
Correct
Page 2 of 3

Section 7 Quiz
(Answer all questions in this section)

11. What is the result of a query that selects from two tables but includes no

A selection of rows from the first table on


A Cartesian product (*)

A selection of matched rows from both tab


A syntax error
Correct
12. The PATIENTS and DOCTORS tables contain these columns:
PATIENTS
PATIENT_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DOCTORS
DOCTOR_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
You issue this statement:
SELECT patient_id, doctor_id
FROM patients, doctors;
Which result will this statement provide?

A report containing all possible combinati

A syntax error

A report containing each patient's id value


A report with NO duplicate PATIENT_ID
Correct
13. Evaluate this SQL statement:

SELECT e.employee_id, e.last_name, e.first_name, d.department_name


FROM employees e, departments d
WHERE e.department_id = d.department_id AND employees.departme
ORDER BY 4;
Which clause contains a syntax error?

WHERE e.department_id = d.department_

SELECT e.employee_id, e.last_name, e.fi


ORDER BY 4;

AND employees.department_id > 5000 (*


FROM employees e, departments d
Correct

14. If table A has 10 rows and table B has 5 rows, how many rows will be r

5
10
50 (*)
15
Correct

15. What is produced when a join condition is not specified in a multiple-ta

An outer join
An equijoin
A self-join

A Cartesian product (*)


Correct
Page 3 of 3

Section 8 Quiz
(Answer all questions in this section)
1.The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(7,2)
DEPARTMENT_ID NUMBER(9)
You need to display the number of employees whose salary is greater
than $50,000? Which SELECT would you use?
SELECT * FROM employees
WHERE salary > 50000;
SELECT * FROM employees
WHERE salary < 50000;
SELECT COUNT(*)
FROM employees
WHERE salary > 50000
GROUP BY employee_id, last_name, first_name, salary,
department_id;
SELECT COUNT(*)
FROM employees
WHERE salary < 50000;
SELECT COUNT(*)
FROM employees
WHERE salary > 50000;
(*)
Correct

Mark for Review


(1) Points

2.Evaluate this SELECT statement:


SELECT COUNT(*)
FROM employees
WHERE salary > 30000;

Mark for Review


(1) Points

Which result will the query display?


The total of the SALARY column for all employees that have a
salary greater than 30000
The query generates an error and returns no results.
The number of employees that have a salary less than 30000
The number of rows in the EMPLOYEES table that have a salary
greater than 30000 (*)
Correct
3.To include null values in the calculations of a group function, you
must:

Mark for Review


(1) Points

Precede the group function name with NULL


Convert the null to a value using the NVL( ) function (*)
Count the number of null values in that column using COUNT
Group functions can never use null values
Correct
4.Evaluate this SQL statement:
SELECT COUNT (amount)
FROM inventory;
What will occur when the statement is issued?
The statement will return the total number of rows in the
AMOUNT column.
The statement will return the greatest value in the INVENTORY
table.
The statement will count the number of rows in the INVENTORY
table where the AMOUNT column is not null. (*)
The statement will replace all NULL values that exist in the
AMOUNT column.

Mark for Review


(1) Points

Correct
5.What would the following SQL statement return?

Mark for Review

SELECT COUNT(DISTINCT salary)


FROM employees;

(1) Points

The total number of rows in the employees table


A listing of all unique salaries in the employees table
The total amount of salaries in the employees table
The number of unique salaries in the employees table (*)
Correct
Page 1 of 3
Section 8 Quiz
(Answer all questions in this section)
6. The STYLES table contains this data:

Mark for Review

STYLE_ID

STYLE_NAME

CATEGORY

COST

895840

SANDAL

85940

12.00

968950

SANDAL

85909

10.00

869506

SANDAL

89690

15.00

809090

LOAFER

89098

10.00

890890

LOAFER

89789

14.00

857689

HEEL

85940

11.00

758960

SANDAL

86979

You issue this SELECT statement:


SELECT COUNT(category)
FROM styles;
Which value is displayed?
The statement will NOT execute successfully.
0
7 (*)

(1) Points

6
Correct
7. Using your existing knowledge of the employees table,
would the following two statements produce the same
result?

Mark for Review


(1) Points

SELECT COUNT(*)
FROM employees;
SELECT COUNT(commission_pct)
FROM employees;
Yes
No (*)
The second statement is invalid
The first statement is invalid
Correct
8. You can use GROUP functions in all clauses of a
SELECT statement. True or False?

Mark for Review


(1) Points

True
False (*)
Correct
9. Given the following data in the employees table
(employee_id, salary, commission_pct)
DATA: (143, 2600, null
144, 2500, null
149, 10500, .2
174, 11000, .3
176, 8600, .2
178, 7000, .15)
What is the result of the following statement:

Mark for Review


(1) Points

SELECT SUM(commission_pct), COUNT(salary)


FROM employees
WHERE employee_id IN( 143,144,149,174,176,178);
SUM = 1.85 and COUNT = 6
SUM = 1.85 and COUNT =4
SUM = .85 and COUNT = 6 (*)
SUM = .85 and COUNT = 4
Incorrect. Refer to Section 8 Lesson 1.
10. What two group functions can be used with any
datatype?

Mark for Review


(1) Points

COUNT, SUM
SUM, AVG
STDDEV, VARIANCE
MIN, MAX (*)
Correct
Page 2 of 3

Section 8 Quiz
(Answer all questions in this section)
11. Which group function would you use to display the lowest value in the

MIN (*)
COUNT
AVG

MAX
Correct
12. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(9,2)
HIRE_DATE DATE
BONUS NUMBER(7,2)
COMM_PCT NUMBER(4,2)

Which three functions could be used with the HIRE_DATE, LAST_NA


(Choose all correct answers)
MIN (*)
COUNT (*)
MAX (*)
SUM
AVG
Correct

13. Which aggregate function can be used on a column of the DATE data ty

STDDEV
AVG
SUM
MAX (*)
Correct

14. Given the following data in the employees table (employee_id, salary, c
DATA: (143, 2600, null
144, 2500, null
149, 10500, .2

174, 11000, .3
176, 8600, .2
178, 7000, .15)
What is the result of the following statement:
SELECT AVG(commission_pct)
FROM employees
WHERE employee_id IN( 143,144,149,174,176,178);
0.2125 (*)
1.2125
0.0425
This statement is invalid
Correct

15. Which group functions below act on character, number, and date data ty

(Choose all correct answers)


AVG
SUM
COUNT (*)
MAX (*)
MIN (*)
Correct
Page 3 of 3

Section 9 Quiz
(Answer all questions in this section)
1. The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER(9) PK

CATEGORY_ID VARCHAR2(10)
LOCATION_ID NUMBER(9)
DESCRIPTION VARCHAR2(30)
COST NUMBER(7,2)
PRICE NUMBER(7,2)
QUANTITY NUMBER

You display the total of the extended costs for each product category by location
You need to include only the products that have a price less than $25.00.
The extended cost of each item equals the quantity value multiplied by the cost v
Which SQL statement will display the desired result?

SELECT SUM(cost * quantity) TOTAL


FROM products
WHERE price < 25.00;
SELECT category_id, SUM(cost * quantity) TOTA
FROM products
WHERE price > 25.00
GROUP BY category_id, location_id;
SELECT SUM(cost * quantity) TOTAL, location_
FROM products
WHERE price < 25.00
GROUP BY location_id;
SELECT category_id, SUM(cost * quantity) TOTA
FROM products
WHERE price < 25.00
GROUP BY category_id, location_id;
(*)
Correct
2. The PAYMENT table contains these columns:
PAYMENT_ID NUMBER(9) PK
PAYMENT_DATE DATE
CUSTOMER_ID NUMBER(9)

Which SELECT statement could you use to display the number of times each cu

SELECT customer_id, COUNT(payment_id)


FROM payment
WHERE payment_date BETWEEN '01-JAN-2003

SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003
GROUP BY customer_id;
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003
GROUP BY customer_id;
(*)
Correct
3. What is the correct order of clauses in a SELECT statement?

SELECT
FROM
WHERE
HAVING
ORDER BY
GROUP BY
SELECT
FROM
WHERE
ORDER BY
GROUP BY
HAVING
SELECT
FROM
HAVING
GROUP BY
WHERE
ORDER BY
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY

(*)
Correct

4. You want to write a report that returns the average salary of all employees in the
The EMPLOYEES table contains the following columns:
EMPLOYEES:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which SELECT statement will return the information that you require?
SELECT salary(AVG), dept
FROM employees
GROUP BY dept;
SELECT AVG salary
FROM employees
BY dept;
SELECT dept, AVG(salary)
FROM employees
GROUP BY dept;
(*)
SELECT AVG (salary)
FROM employees
BY dept;
Correct
5. The EMPLOYEES table contains the following columns:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)

You want to create a report that includes each employee's last name, employee id
Which of the following SELECT statements will accomplish this task?

SELECT employee_id, last_name, hire_date, salar


FROM employees
WHERE salary > 40000
AND (sysdate-hire_date) / 365 > 1;
(*)

SELECT employee_id, last_name, hire_date, salar


FROM employees
WHERE salary > 40000 AND hire_date =
(SELECT hire_date
FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
SELECT employee_id, last_name, salary
FROM employees
WHERE salary > 40000
AND hire_date =
(SELECT hire_date
FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
SELECT employee_id, last_name, salary
FROM employees
WHERE salary > 40000
AND hire_date IN (sysdate-hire_date) / 365 > 1);
Correct
Page 1 of 3
Section 9 Quiz
(Answer all questions in this section)
6. Evaluate this SELECT statement:
SELECT COUNT(employee_id), department_id
FROM employees
GROUP BY department_id;
You only want to include employees who earn more than
15000.
Which clause should you include in the SELECT

Mark for Review


(1) Points

statement?
WHERE salary > 15000 (*)
HAVING SUM(salary) > 15000
WHERE SUM(salary) > 15000
HAVING salary > 15000
Correct
7. The difference between UNION and UNION ALL is

Mark for Review


(1) Points

There is no difference; you get exactly the same


result from both.
UNION ALL is more like a NATURAL JOIN.
UNION will remove duplicates; UNION ALL returns
all rows from all queries including the duplicates. (*)
UNION is a synomym for UNION ALL.
Correct
8. When using SET operators, the number of columns and
the data types of the columns must be identical in all of
the SELECT statements used in the query. True or False.

Mark for Review


(1) Points

True (*)
False
Correct
9. Which of the following are correct SET operators?
(choose two)

Mark for Review


(1) Points

(Choose all correct answers)


UNION ALL, PLUS ALL
UNION ALL, INTERSECT (*)
MINUS, PLUS
UNION, MINUS (*)

Correct
10. If you want to include subtotals and grand totals for all
columns mentioned in a GROUP BY clause, you should
use which of the following extensions to the GROUP BY
clause?

Mark for Review


(1) Points

GROUP BY ALL COLUMNS


CUBE (*)
HAVING
ROLLUP
Correct
Page 2 of 3

Section 9 Quiz
(Answer all questions in this section)

11. You use GROUPING functions to ______ database rows from tabulated

COUNT
COMPUTE
CREATE
DISTINGUISH (*)
Correct

12. CUBE can be applied to all aggregate functions including AVG, SUM, M

True (*)
False
Correct

13. Examine the following statement:


SELECT department_id, manager_id, job_id, SUM(salary)
FROM employees
GROUP BY ROLLUP(department_id, manager_id)
What extra data will this query generate?

Subtotals for department_id, and grand tot

Subtotals for department_id, job_id and gr

Subtotals for department_id, job_id, mana


The statement will fail. (*)
Correct
14. You use ROLLUP to:

produce a single result set


produce subtotal values (*)
cross-tabulate values
Correct
15. You use GROUPING functions to:

Aggregate rows using SUM, MIN, MAX,

Identify the extra row values created by ei

Produce subtotal and cross-tabulated value


Correct
Page 3 of 3

Section 10 Quiz

(Answer all questions in this section)


1.Which statement about single-row and multiple-row subqueries is
true?

Mark for Review


(1) Points

Single-row operators can be used with both single-row and


multiple-row subqueries.
Multiple-row subqueries can only be used in SELECT statements.
Multiple-row subqueries cannot be used with the LIKE operator.
(*)
Multiple-row subqueries can be used with both single-row and
multiple-row operators.
Correct
2.Multiple-row subqueries must have NOT, IN, or ANY in the WHERE
clause of the inner query. True or False?

Mark for Review


(1) Points

True
False (*)
Correct
3.Group functions can be used in multiple-row subqueries in the
HAVING and GROUP BY clauses. True or False?

Mark for Review


(1) Points

True (*)
False
Correct
4.The SQL multiple-row subquery extends the capability of the singlerow syntax through the use of which three comparison operators?

Mark for Review


(1) Points

IN, ANY, and ALL (*)


IN, ALL, and EVERY
IN, ANY, and EQUAL
IN, ANY, and EVERY
Correct

5.Group functions can be used in subqueries even though they may


return many rows. True or False?

Mark for Review


(1) Points

True (*)
False
Correct
Section 10 Quiz
(Answer all questions in this section)
6. Evaluate this SQL statement:
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id IN
(SELECT department_id
FROM employees
WHERE salary > 30000 AND salary < 50000);

Mark for Review


(1) Points

Which values will be displayed?


Only employees who earn more than $30,000.
Only employees who earn less than $50,000.
All employees who work in a department with employees who
earn more than $30,000, but less than $50,000. (*)
All employees who work in a department with employees who
earn more than $30,000 and more than $50,000.
Correct
7. The WITH clause enables a SELECT statement to define the
subquery block at the start of the query, process the block just once,
label the results, and then refer to the results multiple times. True or
False?

Mark for Review


(1) Points

True (*)
False
Correct
8. The Oracle server performs a correlated subquery when the subquery
references a column from a table referred to in the parent. True or

Mark for Review

False?

(1) Points

True (*)
False
Correct
9. Which statement is false?

Mark for Review


(1) Points

The WITH clause stores the results for the user who runs the
query.
The WITH clause retrieves the results of one or more query
blocks.
The WITH clause decreases performance. (*)
The WITH clause makes the query simple to read.
Correct
10.The EMPLOYEES and ORDERS tables contain these columns:
EMPLOYEES
EMPLOYEE_ID NUMBER(10) NOT NULL PRIMARY KEY
FIRST_NAME VARCHAR2(30)
LAST_NAME VARCHAR2(30)
ADDRESS VARCHAR2(25)
CITY VARCHAR2(20)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
ORDERS
ORDER_ID NUMBER(10) NOT NULL PRIMARY KEY
EMPLOYEE_ID NUMBER(10) NOT NULL FOREIGN KEY
ORDER_DATE DATE
TOTAL NUMBER(10)
Which SELECT statement will return all orders generated by a sales
representative named Franklin during the year 2001?
SELECT (SELECT employee_id FROM employees WHERE
last_name = 'Franklin') AND order_id, total
FROM ORDERS

Mark for Review


(1) Points

WHERE order_date BETWEEN '01-jan-2001' AND '31-dec2001';


SELECT order_id, total
FROM ORDERS (SELECT employee_id
FROM employees
WHERE last_name = 'Franklin')
WHERE order_date BETWEEN '01-jan-2001' AND '31-dec2001';
SELECT order_id, total
FROM ORDERS
WHERE employee_id = (SELECT employee_id FROM
employees WHERE last_name = 'Franklin')
AND order_date BETWEEN '01-jan-2001' AND '31-dec-2001';
(*)
SELECT order_id, employee_id, total
FROM ORDERS
WHERE order_date BETWEEN '01-jan-2001' AND '31-dec2001' AND emp_id = 'Franklin';
Correct
Page 2 of 3

Section 10 Quiz
(Answer all questions in this section)
11.Which operator can be used with subqueries that return only one
row?

Mark for Review


(1) Points

IN
LIKE (*)
ALL
ANY
Correct

12.Using a subquery in which clause will return a syntax error?

Mark for Review


(1) Points

FROM
WHERE
You can use subqueries in all of the above clauses. (*)
HAVING
Correct
13.You need to produce a report that contains all employee-related
information for those employees who have Brad Carter as a
supervisor. However, you are not sure which supervisor ID belongs
to Brad Carter. Which query should you issue to accomplish this
task?
SELECT *
FROM employees
WHERE supervisor_id =
(SELECT employee_id
FROM employees
WHERE last_name = 'Carter');
(*)
SELECT *
FROM supervisors
WHERE supervisor_id =
(SELECT employee_id
FROM supervisors
WHERE last_name = 'Carter');
SELECT *
FROM supervisors
WHERE supervisor_id =
(SELECT supervisor_id
FROM employees
WHERE last_name = 'Carter');
SELECT *
FROM employees
WHERE supervisor_id = (SELECT supervisor_id
FROM employees
WHERE last_name = 'Carter');
Incorrect. Refer to Section 10 Lesson 2.

Mark for Review


(1) Points

14.If a single-row subquery returns a null value and uses the equality
comparison operator, what will the outer query return?

Mark for Review


(1) Points

All the rows in the table


An error
A null value
No rows (*)
Correct
15.Subqueries are limited to four per SQL transaction. True or False?

Mark for Review


(1) Points

True
False (*)
Correct
Page 3 of 3

You might also like