Index: /branches/release-39/lib/MT/Object.pm
===================================================================
--- /branches/release-39/lib/MT/Object.pm (revision 2453)
+++ /branches/release-39/lib/MT/Object.pm (revision 2459)
@@ -707,4 +707,5 @@
 sub sum_group_by   { shift->_proxy('sum_group_by',   @_) }
 sub avg_group_by   { shift->_proxy('avg_group_by',   @_) }
+sub max_group_by   { shift->_proxy('max_group_by',   @_) }
 sub remove_all     { shift->_proxy('remove_all',     @_) }
 
@@ -2041,4 +2042,18 @@
         avg => 'property_to_average' })
 
+=head2 Max by Group
+
+=over 4
+
+=item * Class->max_group_by()
+
+=back
+
+Like the count_group_by method, you can select objects from a MT::Object
+store using a SQL 'MAX' operator.
+
+    my $iter = MT::Foo->max_group_by($terms, {%args, group => $group_exprs,
+        max => 'column_name' })
+
 =head2 Sum by Group
 
Index: /branches/release-39/lib/MT/ObjectDriver/Driver/DBI.pm
===================================================================
--- /branches/release-39/lib/MT/ObjectDriver/Driver/DBI.pm (revision 2202)
+++ /branches/release-39/lib/MT/ObjectDriver/Driver/DBI.pm (revision 2459)
@@ -116,4 +116,16 @@
     $args->{direction} = 'descend' unless exists $args->{direction};
     $driver->_do_group_by("AVG($avg_column) AS avg_$avg_column", @_);
+}
+
+sub max_group_by {
+    my $driver = shift;
+    my ($class, $terms, $args) = @_;
+
+    my $max_column = delete $args->{max};
+    return unless $max_column;
+    $max_column = $driver->_decorate_column_name($class, $max_column);
+    $args->{sort} = "max_$max_column" unless exists $args->{sort};
+    $args->{direction} = 'descend' unless exists $args->{direction};
+    $driver->_do_group_by("MAX($max_column) AS max_$max_column", @_);
 }
 
