当前位置: 代码迷 >> 综合 >> mysql实现 row_number() over(partition by group_id order by id desc) rn (rn 等同下面代码的rankNum)
  详细解决方案

mysql实现 row_number() over(partition by group_id order by id desc) rn (rn 等同下面代码的rankNum)

热度:52   发布时间:2023-12-12 20:39:54.0
mysql实现 row_number() over(partition by group_id order by id desc) rn  (rn 等同下面代码的rankNum)
```
select
a.id,
a.group_id,
count(1) as rankNum
from ds_group_task a
join ds_group_task b
on a.group_id = b.group_id and a.id <= b.id
group by
a.id,
a.group_id
order by a.id
```

  相关解决方案