QuestionQ114

VerifiedRestricting and Sorting Data

You need to display 5 percent of the rows in the sales table for products with the lowest AMOUNT_SOLD, including any rows with the same AMOUNT_SOLD even if this makes the output exceed 5 percent of the rows.

Which query returns the required result?

Question Image

Explanation

ORDER BY amount_sold orders the products from the lowest amount sold upward. FETCH FIRST 5 PERCENT ROWS WITH TIES returns 5 percent of the selected rows and includes additional rows whose sort key equals that of the last fetched row. Oracle requires an ORDER BY clause for WITH TIES to include tied rows.

Learn more

Community Discussion

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