--drop table GroupIdentifierTest
go
Create table GroupIdentifierTest
(
RowId varchar(10),
[Delimiter] int
)
insert into GroupIdentifierTest
select 'a', 0 union all
select 'b', 0 union all
select 'c', 0 union all
select 'd', 1 union all
select 'e', 0 union all
select 'f', 1
select * from GroupIdentifierTest
delete GroupIdentifierTest
insert into GroupIdentifierTest
select 'a', 1 union all
select 'b', 1 union all
select 'c', 1 union all
select 'd', 2 union all
select 'e', 2 union all
select 'f', 2
select r.RowId, r.Delimiter As GroupId from GroupIdentifierTest r
如果你有一个行集,并且数据在分组中,由列值1表示,你如何生成GroupId数字?
在此示例中,需要将第一个行集转换为第二个行集。
答案 0 :(得分:0)
您需要多少组?也许这会有所帮助:
RowId groupID
---------- -----------
a 1
b 1
c 1
d 2
e 2
f 2
结果:
{{1}}