Quiz: Conditional Expressions

Test: Quiz: Conditional Expressions

Section 1

1. For the given data from Employees (last_name, manager_id) what is the result of the following statement:

DATA:

( King, null

Kochhar, 100

De Haan, 100

Hunold, 102

Ernst, 103)

SELECT last_name,

DECODE(manager_id, 100, 'King', 'A N Other') "Works For?"

FROM employees

Mark for Review

(1) Points

King, Null

Kochhar, King

De Haan, King

Hunold, A N Other

Ernst, A N Other

King, A N Other

Kochhar, King

De Haan, King

Hunold, A N Other

Ernst, A N Other(*)

Invalid statement.

King, A N Other

Kochhar, King

De Haan, King

Hunold, Kochhar

Ernst, De Haan

Correct Correct

2. CASE and DECODE evaluate expressions in a similar way to IF-THEN-ELSE logic. However, DECODE is specific to Oracle syntax. True or False? Mark for Review

(1) Points

True (*)

False

3. Which of the following is a conditional expression used in SQL? Mark for Review

(1) Points

CASE (*)

DESCRIBE

WHERE

NULLIF

4. Which statement will return a listing of last names, salaries and a rating of 'Low', 'Medium', 'Good' or 'Excellent' depending on the salary value? Mark for Review

(1) Points

SELECT last_name,salary,

(CASE WHEN salary < 5000 THEN 'Low' WHEN salary < 10000 THEN 'Medium' WHEN salary < 20000 THEN 'Good' ELSE 'Excellent' END) qualified_salary FROM employees; (*)

SELECT last_name,salary, (CASE WHEN sal < 5000 THEN 'Low' WHEN sal < 10000 THEN 'Medium' WHEN sal < 20000 THEN 'Good' ELSE 'Excellent' END) qualified_salary FROM employees; SELECT last_name,sal, (CASE WHEN sal < 5000 THEN 'Low' WHEN sal < 10000 THEN 'Medium' WHEN sal < 20000 THEN 'Good' ELSE 'Excellent' END) qualified_salary FROM employees; SELECT last_name,salary, (RATING WHEN salary < 5000 THEN 'Low' WHEN salary < 10000 THEN 'Medium' WHEN salary < 20000 THEN 'Good' ELSE 'Excellent' END) qualified_salary FROM employees; Correct

Solution for Test: Quiz: Introduction to The Oracle Academy
Solution for Test: Quiz: Data vs Information
Top