Предполагая, что имя таблицы является тестовым (измените, чтобы соответствовать вашему), попробуйте это
CREATE TABLE [dbo].[test](
[name] [varchar](3) NULL,
[code] [varchar](5) NULL,
[RowNumber] [int] NOT NULL,
CONSTRAINT [PK_test] PRIMARY KEY CLUSTERED
(
[RowNumber] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
INSERT INTO [test] ([name],[code],[RowNumber])VALUES('A1','AED',1)
INSERT INTO [test] ([name],[code],[RowNumber])VALUES('A1','BG',2)
INSERT INTO [test] ([name],[code],[RowNumber])VALUES('A1','WS',3)
INSERT INTO [test] ([name],[code],[RowNumber])VALUES('A2','CER',4)
INSERT INTO [test] ([name],[code],[RowNumber])VALUES('A2','HJY',5)
INSERT INTO [test] ([name],[code],[RowNumber])VALUES('A5','OLP',6)
INSERT INTO [test] ([name],[code],[RowNumber])VALUES('A6','LOO',7)
INSERT INTO [test] ([name],[code],[RowNumber])VALUES('A6','AED',8)
SELECT a.*
FROM dbo.test a
INNER JOIN(SELECT name,
MIN(rownumber) AS rownumber
FROM dbo.test
GROUP BY name) b
ON a.name = b.name
AND a.rownumber = b.rownumber
ORDER BY a.name
Если столбец RowNumber всегда будет последовательным, поместите индекс в этот столбец.