попробуйте это (работает на SQL Server 2005):
declare @yourtable table (rowid int, a int,b char(3))
insert into @yourtable values (1,10,'ABC')
insert into @yourtable values (2,10,'ABC')
insert into @yourtable values (3,10,'FFF')
insert into @yourtable values (4,20,'HHH')
;WITH YourTableCTE AS
(
SELECT
*, ROW_NUMBER() OVER(partition by A ORDER BY A ASC,CountOfB DESC) AS RowRank
FROM (SELECT
A, B, COUNT(B) AS CountOfB
FROM @yourtable
GROUP BY A,B
) dt
)
SELECT
A,B
FROM YourTableCTE
WHERE RowRank=1
РЕДАКТИРОВАТЬ без CTE ...
SELECT
A,B
FROM (SELECT
*, ROW_NUMBER() OVER(partition by A ORDER BY A ASC,CountOfB DESC) AS RowRank
FROM (SELECT
A, B, COUNT(B) AS CountOfB
FROM @yourtable
GROUP BY A,B
) dt
) dt2
WHERE RowRank=1