$ 0 0 Simply remove the [PARTITION] parts from the ON join clauses, and from the GROUP BY and SELECT clauses.