我已经查看了其他问题并且无法找到我正在寻找的东西我有一个SQL数据库,其中有一个名为InventoryAllocations的表.在表格中,我有多个DocumentID条目,并希望检索每个唯一DocumentID的最后一个条目.我可以通过执行来检索一个
SELECT top(1) [UID]
,[RecordStatusID]
,[CreatedDate]
,[CreatedTime]
,[CreatedByID]
,[OperationType]
,[InventoryLocationID]
,[DocumentTypeID]
,[DocumentID]
,[SOJPersonnelID]
,[InventorySerialisedItemID]
,[TransactionQty]
,[TransactionInventoryStatusID]
,[Completed]
,[CreatedByType]
,[RecordTimeStamp]
FROM [CPData].[dbo].[InventoryAllocations]
order by DocumentID desc
Run Code Online (Sandbox Code Playgroud)
但我想让它带回一个包含所有唯一DocumentID的列表.我希望你能提供帮助.非常感谢Hannah x