How do I get top-N and bottom-N rankings with iDBQuery?
Ask iDBQuery 'Show the top 10 and bottom 10 products by profit this quarter.' It ranks your records on the measure you choose, returns both ends as a chart and table, and cites every entry back to its source rows so each ranking is fully verifiable.
Top-N and bottom-N rankings answer the everyday 'what are the best and worst?' questions, best customers, worst-selling products, slowest-paying accounts. iDBQuery produces them instantly from plain language, no ORDER BY or LIMIT to write.
- You'd ask iDBQuery: 'Show the top 10 customers by revenue and the bottom 10 by gross margin this quarter, side by side.'
- It ranks the records on each measure, returns a bar chart and table for both ends, and includes the values.
- Every entry is cited to its source rows, so 'this is our #1 customer at £310k' is backed by the actual transactions.
Rankings are where analysis usually starts, so iDBQuery makes the next step easy in the same thread: 'For the bottom 10, why is their margin so low?' or 'Show what the top 10 have in common.' It keeps the context and drills in. Because the ranking may need data from several systems, revenue from billing, margin from an ERP, the one live model joins them so the leaderboard is accurate with no pipeline. You can pin top and bottom lists to a live dashboard that refreshes automatically, and let the Analyst agent surface not just the ranking but what distinguishes the top from the bottom, citing the rows. This is a foundation for Pareto, concentration, and contribution analysis.
Updated 2026-06-22
Related questions
- How do I do percentile analysis (medians, p90, p95) with iDBQuery?
- How do I analyse a distribution or build a histogram with iDBQuery?
- How do I analyse gross margin by product with iDBQuery?
- How do I do a root-cause drilldown to explain a change in a metric with iDBQuery?
- How do I segment customers with iDBQuery?