initial answer.
update to use group_by.