QuestionQ97

VerifiedReporting Aggregated Data Using the Group Functions

Review the PRODUCTS and SALES tables.

Question Image

Question Image

You run the following query to display each product name and the number of times that product has been sold:

Question Image

What occurs when the statement is executed?

Explanation

A FROM-clause subquery acts as a derived table whose selected columns, including the COUNT(*) alias item_cnt, are available to the outer query. The grouping by prod_id is valid, and Oracle supports ANSI outer joins with such a derived table. The right outer join retains every PRODUCTS row and supplies the matching sales count where one exists.

Learn more

Community Discussion

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