On Thursday 09 January 2003 23:06, Benjamin Dixon wrote: > I'm trying to figure out a way to select a group of maximums from a set > such that each value pair's greatest value is in the result set. For > example, let's say I have this table Value_Pairs: > > Name | Value > ------------ > Bob 1 > Joe 7 > Bob 2 > Don 3 > Don 4 > Bob 6 > > The result I want is like this: > > Name | Value > ------------ > Bob 6 //Bob's highest value in the table > Joe 7 //Joe's highest value in the table > Don 4 //Don't highest value in the table > > So I'm looking for distinct maximums. > Is it possible to do this *with a single query* in MySQL? I've tried a > number of things and nothing comes close.
SELECT Name, MAX(Value) FROM Value_Pairs GROUP BY Name. You can also find example in the manual: http://www.mysql.com/doc/en/example-Maximum-column-group.html -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Egor Egorov / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net <___/ www.mysql.com --------------------------------------------------------------------- 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