On Thu, 2003-01-09 at 22:06, Benjamin Dixon wrote:
> 
> Hi all,
> 
> 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
> 


The following might work: 



mysql> select name,max(val) from res group by name ;
+------+----------+
| name | max(val) |
+------+----------+
| Bob  |        6 |
| Don  |        4 |
| Joe  |        7 |
+------+----------+
3 rows in set (0.00 sec)



Regards, KentV





---------------------------------------------------------------
|  /   /             KENT VILHELMSEN  - Eniro
| /   /    
|/\  /   mob +47 40213917 OSLO +47 22583917 STH +46 87043619
/  \/    *  Standardise your content to fit ALL browsers!  * 
---------------------------------------------------------------



> 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.
> 
> ben
> 
> 
> ---------------------------------------------------------------------
> 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


---------------------------------------------------------------------
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

Reply via email to