* Lightware Software
> Say I have the following table (TBL):
>
> KEY GRP VAL
> 1 A 2
> 2 A 3
> 3 A 1
>
> 4 B 2
> 5 B 1
> 6 B 3
>
> "select KEY, max(VAL) from TBL group by GRP" gives:
>
> KEY max(VAL)
> ------------
> 1 3
> 4 3
>
> the desired result though is:
>
> KEY max(VAL)
> ------------
> 2 3
> 6 3
>
> any ideas on how to achieve this ?
There is a special page in the manual for this problem, one of my favorite
sql hacks is the MAX-CONCAT trick:
<URL: http://www.mysql.com/doc/en/example-Maximum-column-group-row.html >
--
Roger