
Code
USE [test]
GO
/****** 对象: Table [dbo].[table1] 脚本日期: 09/22/2009 19:13:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[table1](
[id] [nchar](10) COLLATE Chinese_PRC_CI_AS NULL,
[name] [nchar](10) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
select * from table1 where
id in
( select b.bid from ( select max(id) bid from table1
group by [name]) b
)
select * from table1 a where
a.id=(
select max(id) from table1 b
where a.name=b.name
group by b.name
)