[b]data in myTable[/b]
[COLOR=Blue](id) category name[/COLOR]
(1) a Tom
(2) c Kate
(3) c John
(4) b Jane
(5) [COLOR=Red]a[/COLOR] Min
(6) b Sara
(7) [COLOR=Red]b[/COLOR] Chris
(8) c Ryan
(9) [COLOR=Red]c [/COLOR] Terry
I have the above data in myTable.
The following code produces the following result.
[b]code[/b]
select name
from myTable
group by category
[b]result[/b]
Tom
Jane
Kate
The following is my target result.
[b]target result[/b]
Min
Chris
Terry
The followings are the reasons why Min, Chris and Terry should be produced.
Min has the highest ID(5) between Tom and Min who have the same category value 'a'.
Chris has the highest ID(7) among Jane, Sara and Chris who have the same category value 'b'.
Terry has the highest ID(9) among Kate, John, Ryan and Terry who have the same category value 'c'.
I like to produce my target result in MySQL 4.0.
Can I produce it with your help?