From: Peter Brawley Date: January 30 2006 3:41pm Subject: Re: Sort before grouping List-Archive: http://lists.mysql.com/mysql/194366 Message-Id: <43DE339F.5040509@earthlink.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit David, >I have a table of events at different locations and want to select the >newest one for each location. Famous & oft-asked, how to retrieve a groupwise-max values. See http://dev.mysql.com/doc/refman/5.0/en/example-maximum-column-group-row.html PB ----- David Förster wrote: > Hi, > > is there any way to get datasets sorted before they're grouped by GROUP > BY()? > > I have a table of events at different locations and want to select the > newest one for each location. > > However "SELECT * FROM events GROUP BY location ORDER BY date DESC" > gives me just some event per location and the result sorted by date. > > Thanks in advance > David > > ps: please cc, I'm not on the list > > -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.375 / Virus Database: 267.14.23/243 - Release Date: 1/27/2006