postgraph icon indicating copy to clipboard operation
postgraph copied to clipboard

Add DISTINCT to GROUP BY

Open JoshInnis opened this issue 6 months ago • 0 comments

If these duplicates are undesirable, they can be removed using the DISTINCT clause directly on the GROUP BY. Therefore:

GROUP BY DISTINCT ROLLUP (a, b), ROLLUP (a, c)

is equivalent to

GROUP BY GROUPING SETS (
    (a, b, c),
    (a, b),
    (a, c),
    (a),
    ()
)

JoshInnis avatar Dec 18 '23 19:12 JoshInnis