Skip to content

GROUP BY partitioned_table.id not working anymore after partitioning #634

Answered by keithf4
gitmalong asked this question in Q&A
Discussion options

You must be logged in to vote

Apologies that I didn't get back to answering this sooner. You are correct in that there is no guarantee that col1 is unique across the partition set. The template table is just providing a means to be able to define the unique index since it cannot be defined on the parent.

However the error I don't think is related to this. When you do an aggregate, you usually have to do a group by on all the other columns that are not part of the aggregate, in this case sum(). I rewrote this a bit to show a successful run of the query as I think you originally intended (without data)

SELECT t.col3, t.col2, SUM(o.number)
FROM partman_test.time_taptest_table t
INNER JOIN other o ON o.col3 = t.col3
GROUP…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@gitmalong
Comment options

Answer selected by gitmalong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants