How does iDBQuery work out top-N rankings and "biggest" or "smallest"?

iDBQuery answers ranking questions like "top 10 customers" or "worst-performing products" by writing SQL that aggregates the right measure, orders it, and limits to the number you asked for. It handles ties and the metric to rank by, shows the query, and cites each ranked row back to its source.

"Top", "bottom", "biggest", and "most" are among the most common business questions, and getting them right depends on ranking by the correct measure at the correct grain.

  • Aggregate then order. For "top 10 customers by revenue", iDBQuery sums revenue per customer, sorts descending, and returns the first ten — with the correct grain so a customer isn't split across rows.
  • Rank by what you mean. "Biggest" could be by revenue, volume, or margin; iDBQuery uses the measure implied by your question or asks if it's unclear, and you can switch it in a follow-up.
  • Handles edges. Ties, nulls, and "bottom 5" versus "top 5" are handled in the generated SQL, and you can widen or narrow the N conversationally.

Rankings pair naturally with charts — a top-N usually renders as a clean bar chart — and with drill-downs, where you rank first, then investigate the leaders. Because the SQL is visible and each ranked entry is cited to its source rows, you can confirm the ordering reflects the right metric and that number three really is number three. It's a fast, verifiable way to surface what matters most or least in your data.

Updated 2026-06-22