| 发表于:2007-09-05 11:17:2117楼 得分:0 |
create table #t (jgm varchar(1),fks int, kz varchar(1)) insert #t select '1 ',5, 'p ' union all select '1 ',6, 'z ' union all select '1 ',5, 'f ' union all select '1 ',1, 'x ' 測試數據 select jgm, sum(case kz when 'p ' then 1 when 'z ' then 1 when 'f ' then 1 when 'x ' then -1 end *fks) as fkzs from #t where jgm = '1 ' group by jgm drop table #t -------------------------- jgm fkzs ---- ----------- 1 15 | | |
|