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