日期:2014-05-18 浏览次数:20599 次
select id,name,age from( select px=row_number()over(partition by NAME order by(select 1)),* from tbl )a where px=1
------解决方案--------------------
SELECT * FROM [Users] WHERE [Id] IN(SELECT MAX([Id]) FROM [Users] GROUP BY [Name])
------解决方案--------------------
SELECT * FROM [Users] WHERE [Id] IN(SELECT MAX([Id]) FROM [Users] GROUP BY [Name]) SELECT * FROM [Users] WHERE [Id] IN(SELECT Min([Id]) FROM [Users] GROUP BY [Name]) ----以上所有版本通用 select id,name,age from( select px=row_number()over(partition by NAME order by(select 1)),* from tbl )a where px=1 ---row_number() 只有 2005 版本以上支持
------解决方案--------------------
http://topic.csdn.net/u/20080626/00/43d0d10c-28f1-418d-a05b-663880da278a.html
有FAQ帖子可以参考