对不起,不知道如何用单词来举例(这就是为什么有问题要找答案)。
如果ID值被欺骗,我需要这个序列来增加数量。
ID Sequence Value
1111 0 234324
2222 0 23432
3333 0 324
3333 1 234
3333 2 432234
4444 0 23423
4444 1 234发布于 2019-07-12 11:34:25
你想要row_number()。就像这样:
select t.*,
row_number() over (partition by id order by id) as seqnum
from t;注意:数字将递增,但行将不按任何特定顺序排列。
SQL表表示无序集。你的数据没有明显的排序。您可以更改order by以获得给定id的特定顺序的值。
https://stackoverflow.com/questions/57006181
复制相似问题