我有一张桌子,我希望得到每组的最新条目.这是表格:
DocumentStatusLogs 表
|ID| DocumentID | Status | DateCreated |
| 2| 1 | S1 | 7/29/2011 |
| 3| 1 | S2 | 7/30/2011 |
| 6| 1 | S1 | 8/02/2011 |
| 1| 2 | S1 | 7/28/2011 |
| 4| 2 | S2 | 7/30/2011 |
| 5| 2 | S3 | 8/01/2011 |
| 6| 3 | S1 | 8/02/2011 |
Run Code Online (Sandbox Code Playgroud)
该表将按降序分组DocumentID并按DateCreated降序排序.对于每一个DocumentID,我想获得最新状态.
我的首选输出:
| DocumentID | Status | DateCreated …Run Code Online (Sandbox Code Playgroud)