create proc dp_sumarmyfund1 @Criterion_1 as decimal(6,2),--取出的标准扣款 @Itemnumber_12 char(6),--输入的项目编号 @PYCCBH_1 nvarchar(255), @countnum_1 int,--总节数 @sum_Armyfund decimal(6,2)output as select @Criterion_1=Criterion--将标准扣款给变量 from Armyfund where 项目号=@Itemnumber_12 and 标准值--判断‘标准值’是在20到50还是50到70之间 begin select @sum_Armyfund=@countnum_1*@Criterion_1--总节数乘上标准扣款 select @sum_Armyfund--输出总钱数 end
--告诉你如何取吧,你自己改存储过程declare @t table(项目号 char(4),标准值 int,扣款标准 decimal(5,1)) insert @t select '0001',20,0.2 union all select '0001',50,0.6 union all select '0001',70,0.7 union all select '0002',20,0.2 union all select '0002',50,0.6 union all select '0002',70,0.7--查询 declare @项目号 char(4),@取值 int select @项目号='0001' ,@取值=20 --取耿23在那个段select * from @t a where 项目号=@项目号 and 标准值=isnull(( select min(标准值) from @t where 项目号=a.项目号 and 标准值>=@取值 ),(select max(标准值) from @t where 项目号=a.项目号))
这里我没有看明白: declare @t table(项目号 char(4),标准值 int,扣款标准 decimal(5,1)) insert @t select '0001',20,0.2 union all select '0001',50,0.6 union all select '0001',70,0.7 union all select '0002',20,0.2 union all select '0002',50,0.6 union all select '0002',70,0.7
@Criterion_1 as decimal(6,2),--取出的标准扣款
@Itemnumber_12 char(6),--输入的项目编号
@PYCCBH_1 nvarchar(255),
@countnum_1 int,--总节数
@sum_Armyfund decimal(6,2)output
as
select @Criterion_1=Criterion--将标准扣款给变量
from Armyfund
where 项目号=@Itemnumber_12 and 标准值--判断‘标准值’是在20到50还是50到70之间
begin
select @sum_Armyfund=@countnum_1*@Criterion_1--总节数乘上标准扣款
select @sum_Armyfund--输出总钱数
end
insert @t select '0001',20,0.2
union all select '0001',50,0.6
union all select '0001',70,0.7
union all select '0002',20,0.2
union all select '0002',50,0.6
union all select '0002',70,0.7--查询
declare @项目号 char(4),@取值 int
select @项目号='0001'
,@取值=20 --取耿23在那个段select *
from @t a
where 项目号=@项目号 and 标准值=isnull((
select min(标准值) from @t
where 项目号=a.项目号 and 标准值>=@取值
),(select max(标准值) from @t where 项目号=a.项目号))
declare @t table(项目号 char(4),标准值 int,扣款标准 decimal(5,1))
insert @t select '0001',20,0.2
union all select '0001',50,0.6
union all select '0001',70,0.7
union all select '0002',20,0.2
union all select '0002',50,0.6
union all select '0002',70,0.7
项目编号|培养层次编号|阀值|扣款标准|
0001 01 1 0.2
0001 01 19 0.5
0001 01 29 1.0
0002 01 1 0.2
0002 01 19 0.6
0002 01 29 0.6
0003 01 1 0.3
0001 02 1 0.6
0001 02 19 1.0
-------------------
项目编号为 char(6) 代表为 病假、事假、旷课
培养层次编号 nvarchar(255)代表不同的学生身份如:
军培、成人大专、等,
阀值 为病假、事假、旷课的节数不同的培养层次不同节数扣款
是不一样的其中节数大于1小于19扣款为0.2元。
我现在要给出项目编号、培养层次编号 并给出一个节数如15节,
然后用20在阀值列中去进行比较看符合那一段的范围如现在符合
19<20<29 就用20乘上0.5的标准
------------------------------