Quiz 4,5,67
Quiz 4,5,67
Invalid statement.
King, A N Other
Kochhar, King
De Haan, King
Hunold, A N Other
Ernst, A N Other (*)
King, A N Other
Kochhar, King
De Haan, King
Hunold, Kochhar
Ernst, De Haan
King, Null
Kochhar, King
De Haan, King
Hunold, A N Other
Ernst, A N Other
Correct
(1/1) Points
4. If quantity is a number datatype, what is the result of this statement?
SELECT NVL(200/quantity, 'zero') FROM inventory;
ZERO
zero
The statement fails (*)
Null
Correct
(1/1) Points
5. You need to replace null values in the DEPT_ID column with the text N/A. Which
functions should you use?
TO_CHAR and NULLIF
TO_NUMBER and NULLIF
TO_CHAR and NVL (*)
TO_CHAR and NULL
Correct
6. Which statement about group functions is true?
NVL and NVL2, but not COALESCE, can be used with group functions to replace null
values.
NVL and COALESCE, but not NVL2, can be used with group functions to replace null
values.
NVL, NVL2, and COALESCE can be used with group functions to replace null
values. (*)
COALESCE, but not NVL and NVL2, can be used with group functions to replace null
values.
Correct
(1/1) Points
7. Which of the following General Functions will return the first non-null expression
in the expression list?
NVL2
NULLIF
NVL
COALESCE (*)
Correct
(1/1) Points
8. When executed, which statement displays a zero if the TUITION_BALANCE value
is zero and the HOUSING_BALANCE value is null?
SELECT NVL (tuition_balance + housing_balance, 0) "Balance Due"
FROM student_accounts; (*)
SELECT NVL(tuition_balance, 0), NVL (housing_balance), tuition_balance +
housing_balance "Balance Due"
FROM student_accounts;
SELECT TO_NUMBER(tuition_balance, 0), TO_NUMBER (housing_balance, 0),
tutition_balance + housing_balance "Balance Due"
FROM student_accounts;
SELECT tuition_balance + housing_balance
FROM student_accounts;
Correct
(1/1) Points
9. The PRODUCT table contains this column: PRICE NUMBER(7,2)
Evaluate this statement:
SELECT NVL(10 / price, '0')
FROM PRODUCT;
SELECT *
FROM employees
WHERE employee_id = manager_id;
No.ᅠ You will have to re-wirte the statement and perform explicit datatype
conversion.
Yes, Oracle will perform implicit datatype conversion, but the WHERE clause will not
find any matching data. (*)
No, because the datatypes of EMPLOYEE_ID and MANAGER_ID are different.
Yes, Oracle will perform implicit dataype conversion, and the query will return one
row of data.
Correct
(1/1) Points
13. The following script will run successfully. True or False?
SELECT TO_CHAR(TO_DATE('25-Dec-2004','dd-Mon-yyyy'))
FROM dual
True (*)
False
Correct
(1/1) Points
14. If you use the RR format when writing a query using the date 27-Oct-17 and the
year is 2001, what year would be the result?
2017 (*)
1917
2001
1901
Correct
(1/1) Points
15. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
HIRE_DATE DATE
True or False?
True (*)
False
Correct
(1/1) Points
4. What types of joins will return the unmatched values from both tables in the join?
Left outer joins
Right outer joins
Natural joins
Full outer joins (*)
Correct
(1/1) Points
5. For which of the following tables will all the values be retrieved even if there is no
match in the other?
SELECT employees.last_name, employees.department_id,
departments.department_name
FROM employees
LEFT OUTER JOIN departments
ON (employees.department_id = departments.department_id);
employees (*)
Both
department
Neither. The LEFT OUTER JOIN limits the value to the matching department ids.
Correct
6. Which type of join returns rows from one table that have NO direct match in the
other table?
Outer join (*)
Equijoin
Natural join
Self join
Correct
(1/1) Points
7. If you select rows from two tables (employees and departments) using the outer
join specified in the example, what will you get?
SELECT employees.last_name, employees.department_id,
departments.department_name
FROM employees
LEFT OUTER JOIN departments
ON (employees.department_id = departments.department_id);
11. Which of the following database design concepts is implemented with a self
join?
Arc
Supertype
Non-Transferability
Recursive Relationship (*)
Correct
(1/1) Points
12. Evaluate this SELECT statement:
SELECT *
FROM employee worker JOIN employee manager
ON worker.mgr_id = manager.emp_id;
Which type of join is created by this SELECT statement?
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
(1/1) Points
(+) (*)
||
Correct
(1/1) Points
True or False?
True (*)
False
Correct
(1/1) Points
4. Evaluate this SELECT statement:
The join between the player table and the team table on TEAM_ID
The join between the player table and the team table on MANAGER_ID
The join between the player table and the team table on PLAYER_ID
Correct
(1/1) Points
5. You need to join the EMPLOYEES table and the SCHEDULES table, but the two tables do
not have any corresponding columns. Which type of join will you create?
A non-equijoin (*)
An equijoin
Correct
(1/1) Points
Page 1 of 3 Next
Yes, Oracle will resolve which department_id colum comes from which table.
Yes, there are no syntax errors in that statement
No, Oracle will return a Column Ambiguously Defined error. (*)
No, Oracle will not allow joins in the WHERE clause
Correct
(1/1) Points
9. What is the result of a query that selects from two tables but includes no join
condition?
A Cartesian product (*)
A selection of matched rows from both tables
A selection of rows from the first table only
A syntax error
Correct
(1/1) Points
10. Which statement about the join syntax of an Oracle Proprietary join syntax
SELECT statement is true?
The ON keyword must be included.
The WHERE clause represents the join criteria. (*)
The JOIN keyword must be included.
The FROM clause represents the join criteria.
Incorrect. Refer to Section 7 Lesson 1.
11. If table A has 10 rows and table B has 5 rows, how many rows will be returned if
you perform a equi-join on those two tables?
10
5
50
It depends on how many rows have matching data in each of the two tables. (*)
Incorrect. Refer to Section 7 Lesson 1.
(0/1) Points
12. 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.department_id > 5000
ORDER BY 4;
ORDER BY 4;
WHERE e.department_id = d.department_id
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
AND employees.department_id > 5000 (*)
FROM employees e, departments d
Correct
(1/1) Points
13. You have two tables named EMPLOYEES and SALES. You want to identify the
sales representatives who have generated at least $100,000 in revenue.
Which query should you issue?
SELECT e.first_name, e.last_name, s.sales
FROM employees e, sales s
WHERE e.employee_id = s.employee_id AND revenue >= 100000; (*)
SELECT e.first_name, e.last_name, s.sales
FROM employees e, sales s
WHERE e.employee_id = s.employee_id AND revenue > 100000;
SELECT e.first_name, e.last_name, s.sales
FROM employees, sales
WHERE e.employee_id = s.employee_id AND revenue >= 100000;
SELECT first_name, last_name, sales
FROM employees e, sales s
WHERE e.employee_id = s.employee_id AND revenue > 100000;
Correct
(1/1) Points
14. 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
DOCTORS
DOCTOR_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
You need to display the number of employees whose salary is greater than
$50,000? Which SELECT would you use?
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 * FROM employees
WHERE salary > 50000;
SELECT COUNT(*)
FROM employees
WHERE salary < 50000;
SELECT * FROM employees
WHERE salary < 50000;
Correct
(1/1) Points
2. 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)
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.
The statement will return the greatest value in the INVENTORY table.
The statement will return the total number of rows in the AMOUNT column.
Correct
(1/1) Points
5. Which SELECT statement will calculate the number of rows in the PRODUCTS
table?
SELECT ROWCOUNT FROM products;
SELECT COUNT (*) FROM products; (*)
SELECT COUNT(products);
SELECT COUNT FROM products;
Correct
Section 8
(Answer all questions in this section)
6. Which statement about the COUNT function is true?
The COUNT function always ignores null values by default. (*)
The COUNT function ignores duplicates by default.
The COUNT function can be used to find the maximum value in each column.
The COUNT function can be used to determine the number of unique, non-null
values in a column.
Correct
(1/1) Points
7. Examine the data from the LINE_ITEM table:
LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT
890898 847589 848399 8.99 0.10
768385 862459 849869 5.60 0.05
867950 985490 945809 5.60
954039 439203 438925 5.25 0.15
543949 349302 453235 4.50
You query the LINE_ITEM table and a value of 5 is returned. Which SQL statement
did you execute?
SELECT SUM(discount)
FROM line_item;
SELECT AVG(discount)
FROM line_item;
SELECT COUNT(discount)
FROM line_item;
SELECT COUNT(*)
FROM line_item; (*)
Correct
(1/1) Points
8. 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)
SELECT AVG(commission_pct)
FROM employees
WHERE employee_id IN( 143,144,149,174,176,178);
0.2125 (*)
0.0425
1.2125
This statement is invalid
Correct
(1/1) Points
9. 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_NAME, or SALARY
columns? (Choose three.)
TEAMS
TEAM_ID NUMBER NOT NULL, PRIMARY KEY
TEAM_NAME VARCHAR2 (25)
You need to create a report that lists the names of each team with more than three
goal keepers.
Which SELECT statement will produce the desired result?
A list of last_names and salaries of employees that works in the same department
and has the same job_id as that of employee 103. (*)
A list of last_names or salaries of employees that works in the same department
and has the same job_id as that of employee 103.
A list of last_names and salaries of employees that works in the same department
or has the same job_id as that of employee 103.
Nothing. It is an invalid statement.
Correct
(1/1) Points
4. Which best describes a single-row subquery?
A query that returns only one row from the inner SELECT statement (*)
A query that returns one or more rows from the inner SELECT statement
A query that returns only one column value from the inner SELECT statement
A query that returns one or more column values from the inner SELECT statement
Correct
(1/1) Points
5. If the subquery returns no rows, will the outer query return any values?
No, because the subquery will be treated like a null value. (*)
Yes. It will just run and ignore the subquery.
Yes, Oracle will find the nearest value and rewrite your statement implicitly when
you run it.
No, because you are not allowed to return empty values from a subquery.
Correct
6. Which statement about the <> operator is true?
The <> operator returns the same result as the ANY operator in a subquery.
The <> operator is NOT a valid SQL operator.
The <> operator can be used when a single-row subquery returns only one row. (*)
The <> operator CANNOT be used in a single-row subquery.
Correct
(1/1) Points
7. In a subquery, the ALL operator compares a value to every value returned by the
inner query. True or False?
True (*)
False
Correct
(1/1) Points
8. Examine the data in the PAYMENT table:
The department ID, last name, and job ID from departments for Executive
employees
The department ID, last name, and job ID for every employee in the Executive
department (*)
The department ID, last name, and department name for every Executive in the
employees table
The department ID, department name, and last name for every employee in the
Executive department
Correct
11. What is wrong with the following query?
SELECT employee_id, last_name
FROM employees
WHERE salary =
(SELECT MIN(salary) FROM employees GROUP BY department_id);
Nothing, it will run without problems.
Subquery returns more than one row and single row comparison operator is
used. (*)
Single rows contain multiple values and a logical operator is used.
Subquery references the wrong table in the WHERE clause.
Correct
(1/1) Points
12. Examine the structures of the PARTS and MANUFACTURERS tables:
PARTS:
PARTS_ID VARCHAR2(25) PK
PARTS_NAME VARCHAR2(50)
MANUFACTURERS_ID NUMBER
COST NUMBER(5,2)
PRICE NUMBER(5,2)
MANUFACTURERS:
ID NUMBER PK
NAME VARCHAR2(30)
LOCATION VARCHAR2(20)
Assume that the tables have been populated with data including 100 rows in the
PARTS table, and 20 rows in the MANUFACTURERS table. Which SQL statement
correctly uses a subquery?