Q&A for people interested in the history and origins of science and mathematics
create table #temp ( journalSurrogateKey int, companyCode int, reportingLanguage varchar(20) ) insert into #temp values (1, 1, 'DE') insert into #temp values (2, 2, 'EN') insert into #temp values (3, 2, 'EN') insert into #temp values (4, 3, 'DE') insert into #temp values (5, 3, 'EN') SELECT journalSurrogateKey , dense_rank() OVER ( ORDER BY companyCode , reportingLanguage ) AS JEAdditionalAttributeSurrogateKey , companyCode , reportingLanguage FROM #temp