Mysql 查询 两个count 之后的排名

保密保密 发布于 2015/07/06 16:12
阅读 479
收藏 0
+---------+----+------------+--------+---------------+------------+
| user_id | id | follow_uid | status | department_id | created_at |
+---------+----+------------+--------+---------------+------------+
| 1 | 1 | 1 | 2 | 1 | 1 |
| 1 | 2 | 2 | 2 | 1 | 1 |
| 1 | 3 | 3 | 2 | 1 | 1 |
| 2 | 4 | 4 | 2 | 1 | 1 |
| 3 | 5 | 4 | 2 | 1 | 1 |
+---------+----+------------+--------+---------------+------------+


怎么查出 user_id = 1 AND department_id = 1 的总记录数(count) 在 department_id = 1 里的排名是几?
加载中
返回顶部
顶部