Comments on: How to find the max row per group in SQL without subqueries http://www.xaprb.com/blog/2007/03/14/how-to-find-the-max-row-per-group-in-sql-without-subqueries/ Stay curious! Fri, 10 May 2013 18:25:19 +0000 hourly 1 http://wordpress.org/?v=3.5.1 By: David Kleszyk http://www.xaprb.com/blog/2007/03/14/how-to-find-the-max-row-per-group-in-sql-without-subqueries/#comment-19835 David Kleszyk Sat, 14 Jan 2012 21:03:43 +0000 http://www.xaprb.com/blog/?p=307#comment-19835 Stumbled on this after being stymied by MySQL 3.23′s lack of sub-queries. Extremely helpful, thanks so much!

]]>
By: Thomas http://www.xaprb.com/blog/2007/03/14/how-to-find-the-max-row-per-group-in-sql-without-subqueries/#comment-19402 Thomas Thu, 09 Jun 2011 21:09:44 +0000 http://www.xaprb.com/blog/?p=307#comment-19402 As a followup, because it took me a few minutes before the facepalm. If you wanted the youngest, coolest kid, because you have multiple kids of the same age (assuming a coolness column), you’d change the join to:

left outer join person as younger on younger.gender = young.gender
and (younger.age young.coolness))

]]>
By: Anonymous http://www.xaprb.com/blog/2007/03/14/how-to-find-the-max-row-per-group-in-sql-without-subqueries/#comment-18998 Anonymous Tue, 21 Dec 2010 19:38:32 +0000 http://www.xaprb.com/blog/?p=307#comment-18998 Thank you so much for this post. The solution I was using with subqueries was horribly inefficient but this did the trick. As you said, it’s surprisingly fast too.

]]>
By: Ali desitero http://www.xaprb.com/blog/2007/03/14/how-to-find-the-max-row-per-group-in-sql-without-subqueries/#comment-18975 Ali desitero Tue, 07 Dec 2010 13:31:21 +0000 http://www.xaprb.com/blog/?p=307#comment-18975 PERFECT!

After spending hours and hours and trying many many different queries, this solution work perfect for me.

very fast on a standart pc with 30.000 rows. Only 0.0399 secs.

Good job!

]]>
By: arun http://www.xaprb.com/blog/2007/03/14/how-to-find-the-max-row-per-group-in-sql-without-subqueries/#comment-18602 arun Thu, 02 Sep 2010 16:51:36 +0000 http://www.xaprb.com/blog/?p=307#comment-18602 the last query and its output do not match … the last age column in output should not be there

]]>