MySQL Forums
Forum List  »  Newbie

selecting the max of a column
Posted by: zvonimir mileta
Date: May 07, 2008 12:02AM

Hi, I need helping sorting and getting some files.

I have these values
[id] | [id2] [date]
1 | 25 | 2007-03-01
2 | 25 | 2008-03-02
3 | 25 | 2008-03-06
4 | 25 | 2008-03-05
5 | 165 | 2008-04-03
9 | 168 | 2008-05-06
10 | 165 | 2008-05-06
11 | 165 | 2008-05-08
12 | 165 | 2008-05-02

and need to get the highest date of each id2
this would have to give me
3|25|2008-03-06
11 | 165 | 2008-05-08
9 | 168 | 2008-05-06

but is giving me:
1 | 25 | 2008-03-06
5 | 165 | 2008-05-08
9 | 168 | 2008-05-06

using SELECT id, id2, max( act_date ) AS act_date
FROM upg
GROUP BY id2

i dont know why id is giving me differents ids

please help anyone

Options: ReplyQuote


Subject
Written By
Posted
selecting the max of a column
May 07, 2008 12:02AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.