如何在VFP 9和SQL服务器中根据组添加自动递增id
How to add auto increment id according to a group in VFP 9 and SQL Server
table格式如下:
No group name
1 abc a
1 xyz c
1 xyz d
现在我希望它像,
No group name
1 abc a
2 abc b
3 abc f
1 xyz c
2 xyz h
1 xyz d
“否”应根据“组”自动递增
谢谢
可以使用窗口函数:
Select group,
name,
row_number() over (partition by group order by name) as No
from table
table格式如下:
No group name
1 abc a
1 xyz c
1 xyz d
现在我希望它像,
No group name
1 abc a
2 abc b
3 abc f
1 xyz c
2 xyz h
1 xyz d
“否”应根据“组”自动递增 谢谢
可以使用窗口函数:
Select group,
name,
row_number() over (partition by group order by name) as No
from table