create table t(序号 int,姓名 varchar(8),性别 varchar(8),赔偿年限 numeric(3,1),与受害者关系 varchar(8),共同扶养人数 int,应得扶养费 numeric(7,2))
insert into t values(1,'A','男',1.2,'儿子',2,null)
insert into t values(2,'B','女',3.4,'女儿',3,null)
insert into t values(3,'B','男', 15,'父亲',2,null)
insert into t values(4,'C','女', 20,'母亲',3,null)
go
select
(6399*(case when 赔偿年限<=3.4 then 1.0/2 else 1.05'
------解决方案-------------------- 15年以后C和D可能已经不在了
------解决方案-------------------- 先看看...好像有点乱...
------解决方案--------------------
------解决方案--------------------
SQL code
--例子数据
declare @cs table(fy int,bl int)
insert @cs select 6399,90
declare @fyr table(xh int,xm varchar(10),pcnx dec(3,1),gtfyr int,fyf dec(10,2))
insert @fyr select 1,'a',1.2,2,0
union all select 2,'b',3.4,2,0
union all select 3,'c',15,3,0
union all select 4,'d',20,3,0
--下面是代码
declare @pcnx dec(3,1),@xs dec(10,6),@fy int,@bl int
select @fy = fy,@bl = bl from @cs
select * into # from @fyr
while exists(select 1 from # where pcnx <>0)
begin
select @pcnx = min(pcnx),@xs = sum(1.0/gtfyr) from # where pcnx <> 0
if @xs*@bl <=100 set @xs = @bl/100.0 else set @xs = 1.0/@xs
update # set pcnx = pcnx - @pcn