Repeated values

Sorry another question. If i have 2 columns. col a repeats values
1,2,3,1,2,3,etc col b has unique values 21,45,78,1,5,8 ect
So i like to build table as
1 21 1
2 45 5
3 78 8
.Ive done a count on col a, but cant work out how to create new col with the values
Regards Robert

please post sample data as follows

create table #robcpettit(a int, b int)

insert into #robcpettit(a, b)
select 2, 2 union

  1. how do you know which column has the unique values and which columns has the non unique columns
  2. is this real world problem or just some course you are taking or interview questions?


Hi, its is just a hobby for me. col a always has the repeating values, and col b has the calculated values.