you're thinking with a human mind instead of thinking on how a database works... with sets of data.
How can you ask a database to return a single set grouped by something and at the same time as for granular records???
When you use groupby, you can just ask for granular records of the columns you grouped for AND aggregates on every other (min, max, count, sum, avg, count distinct, etc).
id--name--variety
1--apple--fruit
2--pear--fruit
3--salad--vegetable
4--spinach--vegetable
5--spinach--vegetable
Let's answer "Please, tell me how many varieties I hold"...
Two. You can have 2 lines back if you group by variety. No more, no less.
"Ok, database, tell me how many of each variety I have"
Always two lines, no more, no less. In addition to variety, you ask for the count of each.
count--variety
2--fruit
3--vegetable
"Ok, database, tell me how many names there are for each variety"
Always two lines. In addition, you ask for the count distinct of fruits
count distinct--variety
2--fruit
2--vegetable
In set theory, THERE'S no way to ask for the id of the original row if you're grouping by something.
However, you can nest queries (or use windowing functions, that ATM aren't in pydal) to first ask the database to group, and then select a record that matches the grouped property plus the aggregate you chose, like "the row in the group that has that variety and has the last id (which is max())".
the first set would be
max(id)--variety
2--fruit
5--vegetable
and the second a join to the original, returning
2--pear--fruit
5--spinach--vegetable
sooooo.... you can have the latest version_date for each item_id (which correspond to max(version_date) for each group), but you can't ask for anything more which isn't an aggregate, like the item name, in a single shot. At least without resorting to more complicated queries.