如何在mysql的groupby之前进行orderby?
我在 mysql order and groupby 找到问题,
但它不起作用,
我得到相同的解决方案:
SELECT *
FROM (
SELECT *
FROM user
ORDER BY create_time DESC
) AS user
GROUP BY user.role
实现列出每个角色的最新用户
,但mysql的视图不能与subselect一起使用。
I find the question at mysql order and groupby
but it not works,
I get the same solution:
SELECT *
FROM (
SELECT *
FROM user
ORDER BY create_time DESC
) AS user
GROUP BY user.role
to implement list the newest user of each role
but mysql's view can't work with subselect.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Mysql 不支持第一个/最后一个函数
您提供的链接中的答案基于 HAVING 将选择最后一项的面:
Mysql doesn't support a first/last function
The answer in the link you provided, is based on the face that HAVING will pick the last item: