QuestionQ59

VerifiedReporting Aggregated Data Using the Group Functions

Examine the structure of the products table:

Question Image

You need to display the names of products with the greatest total value for UNIT_PRICE * QTY_IN_HAND.

Which SQL statement produces the required output?

Question Image

Explanation

MAX(unit_price * qty_in_hand) calculates the single greatest calculated inventory value across all rows. A scalar subquery can supply that one value to the outer WHERE condition, which selects every row whose unit_price * qty_in_hand equals the maximum, including ties. Oracle documents that MAX is an aggregate function and that a scalar subquery returns one column value from one row.

Learn more

Community Discussion

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