0

I need to get all distinct value from db according to their recent/last entryModTime.

For your understanding

id entry_modtime

3  13-12-1977
3  14-12-1977
4  13-12-1977
5  13-12-1977 
2  13-12-1977
3  15-12-1977

In the above table id field is not primary. I need get all data from that table so the output should be,

3 15-12-1977
4 13-12-1977
5 13-12-1977
2 13-12-1977
Adil Shaikh
  • 44,509
  • 17
  • 89
  • 111
Vinoth Babu
  • 6,724
  • 10
  • 36
  • 55

2 Answers2

3

You can group around your id and select the highest date for every id with max()

select id, max(entry_modtime) as latest_entry_modtime
from your_table
group by id
juergen d
  • 201,996
  • 37
  • 293
  • 362
1
select id, max(entry_modtime)
from your_table
group by id
Jayram
  • 18,820
  • 6
  • 51
  • 68