This is what I used, it worked for me.
First make the query for your max :
$collection = Mage::getModel('key/model')->getCollection();
$collection->getSelect()
->reset(Zend_Db_Select::COLUMNS)
->columns(array('id' => 'MAX(`main_table`.id)'))
->group('customer_id');
$select = $collection->getSelect();
Then create the main query and update the "from" part :
$coll = Mage::getModel('key/model')->getCollection();
$coll->getSelect()
->reset(Zend_Db_Select::COLUMNS)
->reset(Zend_Db_Select::FROM)
->from($select, 'id') // Using from with Zend_Db_Select as name auto uses "t" as table alias
->join(
array('main_table' => $collection->getTable('key/model')),
'`t`.id = `main_table`.id',
array('*')
);
This generates a query like this :
SELECT `t`.`id`, `alias`.* FROM (SELECT MAX(`main_table`.id) AS `id` FROM `tablename` AS `main_table` GROUP BY `customer_id`) AS `t` INNER JOIN `tablename` AS `main_table` ON `t`.id = `main_table`.id
This way the collection you get is from your collection classes :
get_class($coll); // (your collection class) -> Mage_Core_Model_Mysql4_Collection_Abstract
get_class($coll->getFirstItem()); // (your model class) -> Mage_Core_Model_Abstract
You can then use that collection for a Grid in the backend (I used 'main_table' as an alias for the joined table for my grid because all needed information are in there).
(in your case just stop at the from part)