I have a table which I want to get the latest entry for each group. Here\'s the table:
DocumentStatusLogs Table
DocumentStatusLogs
|ID| DocumentID | Status
My code to select top 1 from each group
select a.* from #DocumentStatusLogs a where datecreated in( select top 1 datecreated from #DocumentStatusLogs b where a.documentid = b.documentid order by datecreated desc )