日期:2014-05-17 浏览次数:20563 次
--> 测试数据:[test] if object_id('[test]') is not null drop table [test] create table [test]([字段A] varchar(1),[字段B] varchar(4),[字段C] int) insert [test] select 'A','结束',3 union all select 'A','开始',2 union all select 'A','开始',1 union all select 'B','结束',7 union all select 'B','开始',6 union all select 'B','开始',5 union all select 'B','开始',4 union all select 'B','开始',3 union all select 'B','开始',2 union all select 'B','开始',1 union all select 'C','开始',2 union all select 'C','开始',1 union all select 'D','开始',3 union all select 'D','开始',2 union all select 'D','开始',1 select MIN([字段C]) as seq,COUNT([字段B]) as times from test group by [字段B] /* seq times 3 2 1 13 */ 相同内容干嘛要发两次???