--
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[test]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[test]
GO
CREATE TABLE [dbo].[test] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[name] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[score] [int] NULL
) ON [PRIMARY]
GO
truncate table test
Insert into test(name,score)
select 'a',11 union
select 'b',22 union
select 'b',33 union
select 'c',44 union
select 'c',55
--
SELECT * FROM test
select * from test where [id] in (select [id] from
(
select name,id=(select min([id]) from test where [name]=test1.name) from
(select distinct [name] from test)test1
)test2
)
或者
select * from test where [id] in(select min([id]) from test group by name)