Systematic design of multi-join GROUP BY queries

12 points by squadette


unwind

As far as “value multiplication” or duplicate rows, I’d say 90% (?) of the time I’ve made this mistake it’s either

  1. the join key is 2+ columns, and I left a column out
  2. it’s a self-join, and I wrote t.id <> t2.id instead of t.id < t2.id

The “overview” is quite good. I don’t see the problem with a having in a subquery, as long as you know you’re inner joining it, but I might be misunderstanding. Implicit filtering is a really good term, I’ll have to use that. I usually think of it as inner joins finally meeting left joins.