QuestionQ216

VerifiedUsing Conversion Functions and Conditional Expressions

See the Exhibit and review the structure of the PROMOTIONS table:

Exhibit:

Question Image

Using the PROMOTIONS table, you must determine the average cost for all promotions in the ranges $0–2000 and $2000–5000 in category A.

You issue the following SQL statements:

Exhibit:

Question Image

What is the outcome?

Explanation

A searched CASE expression can use compound WHEN conditions and return NULL. Each expression returns PROMO_COST only for category A rows in its specified cost band; AVG ignores the NULL values from all other rows. Therefore, the statement executes and returns the two requested averages. Oracle CASE Expressions, Oracle Aggregate Functions

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!