在 SQL 中使用分区
我的查询有问题。这是查询。
SELECT UserID, MAX(UserName) as UserName, MAX(TransactionTime) as TransactionTime, MAX(LastAction) as LastAction
FROM UserActivities
WHERE OrganizationID = 26465
GROUP BY UserID
特定用户在不同的 TransactionTime 有如此多的记录。 我想将 LastAction 与其他记录一起保存。 我该怎么做呢? SQL分区在这里可以工作吗?
I have a problem with a query. Here is the query.
SELECT UserID, MAX(UserName) as UserName, MAX(TransactionTime) as TransactionTime, MAX(LastAction) as LastAction
FROM UserActivities
WHERE OrganizationID = 26465
GROUP BY UserID
There are so many records for particular user at different TransactionTime.
I want to take LastAction along with other records.
How can I do it?
Is SQL partition will work here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
排名函数可能就是您正在寻找的:
A ranking function is probably what you are looking for: