Not a problem. I think the easist way to do it is SELECT * FROM families ORDER BY score DESC LIMIT 2 Of course you need your grouping statement in there but the ORDER BY section shouldntmake a difference. There are MAX and MIN functions but my understanding is that those will
only return THE highest/lowest values and not say the highest two values. It would work Ibelieve if there were two families with the same highest score. Someone correct me if I'mwrong. -Nick > Hi, > I have a table containing data on a number of families. > > I want to retrieve members of each family that have the two highest > scoring values for a column. i.e the max and second max. > Is there a function similar to max() or greatest() that will return the > top 2 values when grouping by family ID? > > I can do this using perl in about three steps but would rather make > life easier for myself if I can. > > Thanks in advance > Rich > > mysql query > > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <mysql- [EMAIL PROTECTED]> To > unsubscribe, e-mail > <mysql-unsubscribe- [EMAIL PROTECTED]> Trouble > unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php