日期:2014-05-17 浏览次数:20662 次
create table #tb(id int,people1 varchar(10), people2 varchar(10), people3 varchar(10), [date] datetime)
insert into #tb
select 1,'张三',null,null,'2013-10-01'
union all select 2,'李四',null,null,'2013-10-02'
union all select 3,'王五',null,null,'2013-10-03'
union all select 4,'李四','王五',null,'2013-10-03'
union all select 5,'张三','李四','王五','2013-10-04'
union all select 6,'赵六',null,null,'2013-10-10'
union all select 7,'王五','赵六',null,'2013-10-11'
select people1,sum(num) as num
from
(
select people1,case when people1 is not null and people2 is not null and people3 is not null then 0.3
when people1 is not null and people2 is not null then 0.5 else 1 end as num
from #tb
union all
select people2,case when people1 is&