SQL Server - JOINs & Data Grain
4 min read

Your JOIN Is Correct. Your Data Grain Isn’t.

My Table Has 3,200 Accounts. Why Did This JOIN Return 7,841 Rows?

D

Dan Griffin

Senior Data Analyst · September 28, 2026

Your JOIN Is Correct. Your Data Grain Isn’t.
In this article: Learn why JOINs can produce unexpected "duplicate" rows when tables have different grains. This example shows why DISTINCT can hide the real problem and how aligning the data to the required output grain produces a logically correct result.

A SaaS account report should contain 3,200 accounts.

You add support-ticket data.

Now it contains 7,841 rows.

The JOIN is valid. The rows are not random.

The problem is grain.


Suppose these two tables have different grains:

Accounts

  • One row per account

SupportTickets

  • One row per support ticket


Now imagine this data:

Account 201 | Alpine | MRR 8,000 | 2 open tickets

Account 202 | Meridian | MRR 8,000 | 1 open ticket

Account 203 | Vertex | MRR 5,000 | 0 open tickets

The business wants one row per account.


But this query joins an account to every matching open ticket:


Keep Reading

Get free access to the full article

Join data professionals reading weekly SQL tips, career guides, and interview prep — completely free.

No credit card. No spam. Unsubscribe anytime.