日期:2014-05-17 浏览次数:20580 次
--此表我去掉了无关紧要的字段
CREATE TABLE [dbo].[test](
[controlcountid] [int] IDENTITY(1,1) NOT NULL,
[controlid] [int] NULL,
[possibility] [varchar](50) NULL,
[harm] [varchar](50) NULL )
insert into test ('1','1','A',)
insert into test ('1','2','C',)
insert into test ('2','3','D',)
insert into test ('2','4','B',)
insert into test ('3','5','A',)
insert into test ('3','1','D',)
select controlid , Sum(possibility * case harm when 'A' then 1.0 when 'B' then 0.5 when 'C' then 0.2 when 'D' then 0.1 end)
from test
group by controlid