【发布时间】:2020-12-18 01:52:51
【问题描述】:
我很难理解以下查询如何按顺序生成行号。
select id, value, (select count(*) from tbl b where a.id >= b.id) as cnt
from tbl a
我的目标本质上是生成列 cnt,但我无法理解 count 函数是什么以及 where 子句在做什么。
表格tbl。
id value cnt
1 yes 1
3 yes 2
4 yes 3
6 yes 4
9 yes 5
也欢迎任何线索。谢谢! 链接代码here
【问题讨论】: