Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Actually, I've found that this eliminates some Deal_IDs that aren't null, as per @ypercubeᵀᴹ questioning above where he says "Say we have 2 rows, with (deal_id, exchange_id, pub_id): (3389, 4, 1780) and (3390, 4, 1780) (which I think should be coming from the First table) and another (1) row with (NULL, 4, 1780) which should be coming from the Second table. Now the problem is: when we add up the group with (exchange_id, pub_id) = (4, 1780), the summations are not a problem. But which deal_id to show in the result? 3389 or 3390? (because we can only show one)"
Not quite, because We are now missing the Sum of Second_imps, and incremental isn't simply the distinct users from the First table, it's the distinct users from the first table that don't exist in the second
I sort of see what you're saying, it doesn't aggregate because the conditions aren't clear enough. In my head I was hoping for what usually happens in a [left] or [right] join where matches can happen on more than one item Is there a manipulation that we can do so that it's shown on more than one deal_id or is something inherently wrong with the query?
@ypercubeᵀᴹ yes on both accounts, (exchange_id, pub_id, user_id) is unique in each table and the deal_id is in the GROUP BY, have corrected the query above.