日期:2014-05-18 浏览次数:20506 次
declare @T table (userid int,truename varchar(5)) insert into @T select null,null union all select 0,'员工1' union all select 0,'员工2' union all select 1,'张三' union all select 1,'张三' union all select 2,'李四' select case when userid=0 then '一般' else isnull(truename,'特殊') end as truename, count(1) as countnum from @t group by case when userid=0 then '一般' else isnull(truename,'特殊') END /* truename countnum -------- ----------- 李四 1 特殊 1 一般 2 张三 2 */