I believe MySQL does exactly this, but it's been a number of years since I worked with it in any depth.
Re:A query had to go
by default-kramer on Tuesday June 06, 2017 @11:36PM
(#14503559)
Ah, I found it. It turns out if you include nonaggregated columns it will just pick one value from the group arbitrarily.
https://dev.mysql.com/doc/refman/5.5/en/group-by-handling.ht...
Unless MySQL is smart enough to do something like "implicit grouping" where if you group on the primary key it knows that all other columns of that table could also be included in the group... in which case I really should give MySQL another chance!