Home / Learning guides / Data Analytics
The practice notebook · Nagpur

Why SQL Joins Duplicate Rows: A Practice Guide for Nagpur Learners

Understand row grain, one-to-many joins and reconciliation with a small fictional orders exercise.

Data Analytics IT Accurate · 30 October 2026 · 3 minute read

Start with one row’s meaning

A query can run successfully and still answer the wrong question. Before joining tables, write down what one row represents in each table. In an orders table it might be one order; in an order-items table it might be one product line. Joining them naturally produces several rows for an order containing several products. That is not automatically a database error. The mistake happens when an order-level amount is added once for every joined line.

Build a small example you can check

Create fictional order A with an order total of 600 and two item rows worth 200 and 400. Create order B with one item worth 300. A join produces three rows. Adding the repeated order-total column gives 1,500, while the correct total is 900. Adding the item amounts gives 900. Write both results in your notebook and explain why they differ before changing the query.

Choose the calculation before the join

If the question is total revenue by order, aggregate the item rows to one row per order before joining to order-level information. If the question is product quantities, keep item-level detail. Do not add DISTINCT as an automatic repair: two legitimate transactions can share the same amount. Check unmatched keys separately, and decide whether the report should preserve orders with no matching detail.

Turn the exercise into interview evidence

Keep the input rows, your first result, the corrected result and a short explanation of the row grain. Add a second test with two different orders having the same total, and a third with an unmatched order ID. A useful portfolio demonstrates how you checked the answer. When comparing a Data Analytics course in Nagpur, ask whether guided SQL exercises include joins, missing matches and total reconciliation, and confirm the current syllabus before enrolling.

Your practice checklist

  • State the grain of both tables.
  • Count rows before and after joining.
  • Reconcile totals against hand calculations.
  • Explain unmatched records without hiding them.

Further reading: Official technical guidance. The fictional exercises and checklists above are IT Accurate learning examples.

← Explore more learning guides · Visit our Nagpur centre page