SQL 中通过 COUNT() 排序
假设我有一个这样的数据库表:
users
------
id
email
referrerID
我如何按推荐次数最多的成员进行排序?我正在尝试以下内容:
SELECT id, email
FROM users
WHERE 1
ORDER BY COUNT(referrerID) DESC;
但这似乎不起作用。我认为默认值 0 也可能会以某种方式影响这一点。
Let's say I have a database table like this:
users
------
id
email
referrerID
How could I sort by the members with the most referrals? I was trying something along the lines of:
SELECT id, email
FROM users
WHERE 1
ORDER BY COUNT(referrerID) DESC;
But this does not seem to work. I think that the default value 0 may also be affecting this somehow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下澄清
Following clarification