나는 다음과 같은 쿼리를 가지고 :ROW_NUMBER()
declare @temp1 table
(ID1 int not null,
ID2 int not null)
set nocount off
insert into @temp1 values(1453,931)
insert into @temp1 values(1454,931)
insert into @temp1 values(1455,931)
insert into @temp1 values(2652,1101)
insert into @temp1 values(2653,1101)
insert into @temp1 values(2654,1101)
insert into @temp1 values(2655,1101)
insert into @temp1 values(2656,1101)
insert into @temp1 values(3196,1165)
insert into @temp1 values(3899,1288)
insert into @temp1 values(3900,1288)
insert into @temp1 values(3901,1288)
insert into @temp1 values(3902,1288)
--select * from @temp1
select ID1,ID2, ROW_NUMBER() over(partition by ID2 order by ID1) as RowNum1
from @temp1
내가 이제 새 열을 생성 할 일은 원하는 것 그룹의 모든 ID2의 together..ie ID2의 값 1을 가져야한다 (931)를 가진 새로운 칼럼에서 1101은 2, 1165는 3이어야하고 마침내 1288은 4를 가져야합니다 ... 제발 저에게 도움을받을 수 있습니까?
다음 번에 시도하겠습니다. :) –