English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

THis is Our table

John 2
Mary 2
John 3
John 5
Calin 3
i want get this list where max(position) is right
But when i want to have position for 2 John appears to the list.
Max John position is 5
How could I make it right:
select name,max(position) where position=2 group by name;

2006-11-07 21:45:33 · 3 answers · asked by rezamilanx 2 in Computers & Internet Programming & Design

3 answers

Here's a discussion that should help
http://lists.mysql.com/mysql/200959

///

2006-11-07 21:48:59 · answer #1 · answered by jan 7 · 2 0

select name,max(position) from table group by name

2006-11-09 13:01:50 · answer #2 · answered by life goes on... 2 · 0 0

select * from
(
select name,max(position) as Position from T1 group by name
) T2 where position=2

--T1 is Your Original Table
--T2 is virtual

The inner side gives results
name === Position
---------------------------------
Calin === 3
John === 5
Mary === 2

make it as T2

from T2 it can query again to find where position=2

The result will be
name === Position
---------------------------------
Mary === 2

2006-11-08 07:10:45 · answer #3 · answered by safrodin 3 · 0 0

fedest.com, questions and answers