Views + Group By
A bit frustrated with this topic as I've tried many things to no avail. Basically, I just want to add a GROUP BY clause at the end of the views query I've built.
Let's say views were to create a query like SELECT node.nid, comments.cid FROM node LEFT JOIN comment.cid ON comment.nid = node.nid;
This creates multiple entries for the node because there are multiple comments for each node (or something like that). Anyhow, my problem was easily solved when I completely circumvented the drupal system and just wrote the query myself adding a GROUP BY(node.nid) at the end.
I tried investigating the view object, but wasn't really sure what to do with that. How can I edit the view prior to it being processed?
I also tried the other views group by module, but that only made the repetition problem worse. Help?
**Note**
The desired affect I was going for was the most recent comment for each node entry, which I know the above query does not achieve. Instead I ended up with a more complicated subquery used within the LEFT JOIN of the comment.cid = (SELECT cid FROM comments ORDER BY created DESC LIMIT 1). That's probably as a clear as mud, but I thought it was worth a shot.

Search through the modules
I happened to stumble across the following: Views Group By module - how to use it
There are many modules related to views. Some of them should do what you need, else you can take one of them as a model for you customized module.