Section 6 Quiz
Section 6 Quiz
Section 6 Quiz
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)
(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?
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?
True (*)
False
Correct
8. Which statement about a self join is true?
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?
True
False (*)
Correct
12.What happens when you create a Cartesian product?
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)
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?
+
*
(+) (*)
=
Correct
2.Using Oracle Proprietary join syntax, which two operators can be used
in an outer join condition using the outer join operator (+)?
IN and =
AND and = (*)
OR and =
BETWEEN...AND... and IN
Correct
3.Nonequijoins are normally used with which of the following? (Choose
two)
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
Section 7 Quiz
(Answer all questions in this section)
9. Which statement about the join syntax of an Oracle Proprietary join syn
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 syntax error
14. If table A has 10 rows and table B has 5 rows, how many rows will be r
5
10
50 (*)
15
Correct
An outer join
An equijoin
A self-join
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
Correct
5.What would the following SQL statement return?
(1) Points
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
(1) Points
6
Correct
7. Using your existing knowledge of the employees table,
would the following two statements produce the same
result?
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?
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:
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)
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
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?
Which SELECT statement could you use to display the number of times each cu
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?
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
True (*)
False
Correct
9. Which of the following are correct SET operators?
(choose two)
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?
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
Section 10 Quiz
True
False (*)
Correct
3.Group functions can be used in multiple-row subqueries in the
HAVING and GROUP BY clauses. True or False?
True (*)
False
Correct
4.The SQL multiple-row subquery extends the capability of the singlerow syntax through the use of which three comparison operators?
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);
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
False?
(1) Points
True (*)
False
Correct
9. Which statement is false?
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
Section 10 Quiz
(Answer all questions in this section)
11.Which operator can be used with subqueries that return only one
row?
IN
LIKE (*)
ALL
ANY
Correct
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.
14.If a single-row subquery returns a null value and uses the equality
comparison operator, what will the outer query return?
True
False (*)
Correct
Page 3 of 3