我有一张桌子,里面有AppId
, Comment
, TimeStamp
. 表可以有多个相同的条目AppId
。现在我要做的是通过Desc获取Top 1
Comment
每个AppId
订单。TimeStamp
我尝试过类似的东西
SELECT TOP 1 Comment,
AppId
FROM comments
GROUP BY AppId
但这似乎不起作用,因为我收到错误
Column 'comments.Comment' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
有人可以为我指出正确的方向吗?
谢谢