I wrote a query for a report that needed to summarize table data for
different subsets of an ARRAY column. Once I had a working query, I
recreated it in my code using an SQL query builder (the awesome jOOQ in
this case). Unfortunately the output from the generated SQL was different
from the handw
path[4]
as level4, value
FROM bind_group_by
) AS expanded
GROUP BY GROUPING SETS (
(level1, level2, level3, level4),
(level1, level2, level3),
(level1, level2),
(level1),
()
)
ORDER BY 1, 2, 3, 4;
Thanks for the insight,
- Aner
On Wed, Sep 9, 2020 at 1:13 PM Tom Lane wrot
, 2, 3),
(1, 2),
(1),
()
)
ORDER BY 1, 2, 3, 4;
Since I'm generating the SQL I'm not too worried about the readability and
it works with bind variables too. I promise I'll stop thinking after this
one ;-)
Thanks!
- Aner
On Wed, Sep 9, 2020 at 2:45 PM Tom Lane wrote