SELECT ID, AppID, Description, Min([Transaction Date]) AS 'Transacton Date'
FROM AppProsHist
WHERE [Description]='Non-Final Rejection'
GROUP BY ID, AppID, Description
我认为这只允许在我的表格中显示第一个(最早的)交易日期,但是,这仍然显示每个交易日期。有没有办法改变这一点,以便我只收到一个ID,AppID,描述的日期?
答案 0 :(得分:2)
您应该使用ORDER BY
和LIMIT 1
来获取有序集的第一条记录。订购时ASC
或DESC
将设置排序方向。所以试试
SELECT TOP 1 ID, AppID, Description, Min([Transaction Date]) AS TransactionDate
FROM AppProsHist
WHERE [Description]='Non-Final Rejection'
GROUP BY ID, AppID, Description
ORDER BY TransactionDate DESC, ID