I got the following table:
col1 | col2 | col3 | col4 | timestamp
-------------------------------------
1 | ... | ... | ... | 12:01
1 | ... | ... | ... | 12:40
2 | ... | ... | ... | 11:00
2 | ... | ... | ... | 13:00
2 | ... | ... | ... | 12:22
3 | ... | ... | ... | 16:00
3 | ... | ... | ... | 12:10
i want to get each row with max timestamp values grouped by column 1. this means the result have to be the following:
col1 | col2 | col3 | col4 | timestamp
-------------------------------------
1 | ... | ... | ... | 12:40
2 | ... | ... | ... | 13:00
3 | ... | ... | ... | 16:00
my following query works:
SELECT col1, MAX(timestamp)
FROM table
GROUP BY col1
but not this:
SELECT col1, col2, col3, col4, MAX(timestamp)
FROM table
GROUP BY col1