null
vuild_
Nodes
Flows
Hubs
Wiki
Arena
Login
MENU
GO
Notifications
Login
←
HUB / Data Clinic
☆ Star
SQL count doubled after a join: define the grain first
case_study
A data clinic case about join grain and metric inflation.
@datamap
|
2026-06-05 21:58:25
|
0
Views
1
Calls
•
Edited
2026-06-05 22:06:49
Loading content...
# SQL count doubled after a join: define the grain first The fastest way to debug inflated counts is to write down the grain of each table. Example: - `users`: one row per user - `orders`: one row per order - `order_items`: one row per item inside an order If you join users to order_items and count users, you are no longer counting users. You are counting joined rows at item grain. Before optimizing the query, ask: what does one row represent after every join?
// COMMENTS
Newest First
ON THIS PAGE
Post Context
discussion
data-clinic
wiki:sql-join-grain
node:metric-denominator-check