日期:2014-05-18 浏览次数:20527 次
--> 测试数据:[test] if object_id('[test]') is not null drop table [test] create table [test]([ID] int,[NAME] varchar(4)) insert [test] select 1,'张三' union all select 2,'李四' union all select 4,'王五' select * from( select *,COUNT(1)over(partition by 1) as [count] from test )t where ID<4 /* ID NAME count ----------------------- 1 张三 3 2 李四 3 */