问题描述
我想增加一列,然后根据另一列中的值停止并重新开始.
I want to increment a column and then stop and start again based on a value in another column.
例如:
我有一张桌子:
我想实现这一目标:
所以这是基于 True_False 列.当 True_False 为 0 时,中断并重新开始.( True_False = 0 ) 的 Sequence 值不必为 0,也可以为 NULL.
So this is based on True_False column. When True_False is 0 then break and start over again. Sequence value for ( True_False = 0 ) doesn't need to be 0 could be NULL as well.
推荐答案
试试这个:
查询计算字段grp
,该字段标识具有相同True_False
值的连续记录的岛.在外部查询中使用此字段,我们可以枚举这些岛屿中包含的记录,从而获得所需的序列号.
The query calculates field grp
which identifies islands of consecutive records having the same True_False
value. Using this field in an outer query we can enumerate the records contained inside these islands and thus get the required sequence number.
此处演示
这篇关于根据另一列中的值递增然后中断并重新开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!