forum

Home / DeveloperSection / Forums / Select cell from same column with MAX function in mySql

Select cell from same column with MAX function in mySql

Anonymous User182017-Jul-2013
HI developers!

Table for example:

event_id| group_id | updated_at

1 | 1 |2012-01-02

2 | 1 |2012-01-01

3 | 2 |2012-01-01

4 | 2 |2012-01-02

5 | 3 |2012-01-01

I need select all event_id with max date, grouped by group_id. So right result will be:

event_id| group_id | updated_at

1 | 1 |2012-01-02

4 | 2 |2012-01-02

5 | 3 |2012-01-01

Can I select event_id, from the same row that MAX(updated_at) has been selected? 

SELECT event_id, group_id, MAX(updated_at)

FROM my_table

GROUP BY group_id;

Thanks in advance


Updated on 17-Jul-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By