create table #test (pk int, value char(1)) insert into #test values ( 1,'a' ) insert into #test values ( 2,'c' ) insert into #test values ( 3,'b' ) insert into #test values ( 4,'c' ) insert into #test values ( 5,'a' ) SELECT pk, value FROM #test t WHERE pk = (SELECT TOP 1 t2.pk FROM #test t2 WHERE t.value = t2.value ORDER BY value) drop table #testBOb