Q&A for professional and enthusiast programmers
create table #tbl1(a nvarchar(max)) insert into #tbl1 values ('1'),('2'),('3'),('4') create table #tbl2(b nvarchar(max)) insert into #tbl2 values ('a'),('b'),('c'),('d') select a,b,rn from( select #tbl1.a ,#tbl2.b ,row_number() over (partition by #tbl1.a order by #tbl2.b) rn from #tbl1,#tbl2 ) fff-- where rn=1 --SELECT unique_ID , s.f FROM #tbl1 cross apply(select top 1 unique_ID as f from #tbl2) s