本文介绍了Sql server在0.00和0.50之间不能考虑0.50为什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在sql表中两行给出
StartWeight EndWeight Charges AddWeight AddCharges
0.00 0.50 50 0 0
0.60 1.00 100 1 70





声明@Weight十进制

设置@权重= 0.5

查询选择表中的费用@Weight在StartWeight和EndWeight之间



第一期)这是当@Weight小于或等于0.4时它显示50而当重量是0.50然后它显示100我想要显示50在0.5



第二期)与@weight为0.6至1.4时显示100相同,而我想在0.60到1.00之间显示100而不是更大比1.00



我尝试过:



声明@weight十进制,@结果十进制
设置@ weight = 0.50
设置@结果=(从[客户]中选择费用。[CustomerCharges]其中CustomerAccountID = 1和@weight betw een StartWeight和EndWeight)
选择@result作为结果



结果= 100

解决方案



in sql table two rows are given below
StartWeight    EndWeight      Charges    AddWeight     AddCharges
0.00           0.50           50            0              0
0.60           1.00           100           1             70



declare @Weight decimal
set @Weight=0.5
query select Charges from table where @Weight between StartWeight and EndWeight

First Issue) is this when @Weight is less than or equal to 0.4 it show 50 and when weight is 0.50 then it show 100 while i want to show 50 on 0.5

Second Issue) same as when @weight is 0.6 to 1.4 it show 100 while i want to show 100 only between 0.60 to 1.00 not on greater than 1.00

What I have tried:

declare @weight decimal,@result decimal
set @weight=0.50
set @result=(select Charges from [Customer].[CustomerCharges] where CustomerAccountID=1 and @weight between StartWeight and EndWeight)
select @result as Result


Result=100

解决方案



这篇关于Sql server在0.00和0.50之间不能考虑0.50为什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 00:52