Hello i need help with my MYSQL query
i have table
id | tn | title | customer_id |create_time | comment |
1 | 1342 | sample1 | customer1 | 2012-01-01 | hello world |
2 | 1342 | sample1 | customer1 | 2012-01-02 | hello world |
3 | 1342 | sample1 | customer1 | 2012-01-03 | hello new world |
4 | 3362 | sample2 | customer1 | 2012-01-02 | good bye world |
5 | 3362 | sample2 | customer1 | 2012-01-03 | good bye world |
6 | 3362 | sample2 | customer1 | 2012-01-04 | good bye world |
7 | 3362 | sample2 | customer1 | 2012-01-05 | good bye new world |
when i do group by tn i taked
1 | 1342 | sample1 | customer1 | 2012-01-01 | hello world |
4 | 3362 | sample2 | customer1 | 2012-01-02 | good bye world |
but i need to take
3 | 1342 | sample1 | customer1 | 2012-01-03 | hello new world |
7 | 3362 | sample2 | customer1 | 2012-01-05 | good bye new world |
it’s like grouping by tn with maximum id or maximum create_time
How can i do this? Thanks!
1 Answer