How does iDBQuery avoid double-counting duplicate rows?

iDBQuery avoids double-counting by writing SQL with the right grain — using DISTINCT, correct GROUP BY, and joins that don't fan out rows — so a customer isn't counted twice because they have two orders. It shows the SQL and cites source rows, so you can confirm the count matches reality.

Double-counting is one of the most common ways an analysis goes wrong: join a customers table to orders and suddenly "number of customers" is inflated because each customer repeats per order. iDBQuery is designed to avoid that trap.

  • Correct grain. It writes SQL that counts at the level you asked — `COUNT(DISTINCT customer_id)` for unique customers, not raw rows — and structures joins so a one-to-many relationship doesn't multiply your totals.
  • De-duplication on request. If your data genuinely contains duplicate records (the same invoice imported twice), you can ask iDBQuery to identify and exclude them, and it will show which rows it treated as duplicates.
  • Verifiable output. The generated SQL and row-level citations let you check that a count of 5,000 customers really reflects 5,000 distinct people.

There's a related but separate task — finding and cleaning duplicate records in the data itself — which iDBQuery also supports. The point here is that for everyday counting and aggregation, it defaults to the correct grain so your headline numbers don't quietly inflate whenever a join fans out.

Updated 2026-06-22