日期:2014-05-17 浏览次数:20547 次
create table T1
(FID int,FBH int,FMC varchar(10))
insert into T1
select 2, 001, '测试1' union all
select 10, 001, '测试1A' union all
select 5, 002, '鞋子' union all
select 11, 002, '鞋子2号' union all
select 21, 002, '鞋子3号'
select FID,
FBH,
FMC,
row_number() over(partition by FBH order by FID) '序号'
from T1
/*
FID FBH FMC 序号
----------- ----------- ---------- ----------
2 1 测试1 1
10 1 测试1A 2
5 2 鞋子 1
11 2 鞋子2号 2
21 2 鞋子3号 3
(5 row(s) affected)
*/