gpt4 book ai didi

mysql - 如何对数据进行排序,然后在mysql中对行进行编号?

转载 作者:行者123 更新时间:2023-11-30 22:45:28 24 4
gpt4 key购买 nike

<分区>

有行的表格,例如:

+----+
|num |
+----+
| 6 |
| 10 |
| 3 |
+----+

我尝试降序排序,然后对行进行编号

select num, @c:=@c+1 as c from table1 order by num desc;

但这并不是我所需要的。有没有可能得到下面的表格?

+----+----+
|num | c |
+----+----+
| 10 | 1 |
| 6 | 2 |
| 3 | 3 |
+----+----+

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com