List:General Discussion« Previous MessageNext Message » Date:November 10 2006 10:46pm
Subject:MAX() and GROUP BY question
View as plain text  
Hello everybody
Can you explain me please how to get the entire row where ID is maximum per given
Mysql 4.0.xx 

for example:

id status_id    name        date
6     3           name0      date0
5     1           name1      date1
7     4           name3      date3
10   3           name2      date2

If I execute 

SELECT MAX(id), status, name, date FROM table_name WHERE status=3 GROUP BY staus_id
SELECT MAX(id), status, name, date GROUP BY staus_id

only id and status_id will be returned correctly, while name and date can well be from
another row
for example: 10 3 name0 date0

Thanks a lot for any suggestions

MAX() and GROUP BY questioncase510@yahoo.com10 Nov
  • RE: MAX() and GROUP BY questionTim Lucia11 Nov
  • Re: MAX() and GROUP BY questionJochem van Dieten12 Nov
Re: MAX() and GROUP BY questioncase510@yahoo.com12 Nov