© Kim Berg Hansen 2020
K. Berg HansenPractical Oracle SQLhttps://doi.org/10.1007/978-1-4842-5617-6_12

12. Answering Top-N Questions

Kim Berg Hansen1 
(1)
Middelfart, Denmark
 
I think it is extremely few developers that haven’t been asked to create a Top-N report. The questions by the business that can be classified as a Top-N question are legion such as the following:
  • Which of our products sell the most?

  • Which user profiles create the most tweets?

  • Which sales employees generate most leads?

  • Which hotels in the chain have the least complaints?

The last one could strictly speaking be called a Bottom-N question, but that is in principle exactly the same. For a Top-N report, you order the data by a specific descending order and pick the Top-N rows of data. If ...

Get Practical Oracle SQL: Mastering the Full Power of Oracle Database now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.