我有以下sql查询: -
select b.LOGTIME, b.beam_current, b.beam_energy,
case when a.st1_vs1_bag1_onoff=0 and a.logtime=c.logtime then c.st1_vs1_bag1_rb ELSE 0 END as st1_vs1_bag1_rb ,
CASE when a.st1_vs1_bag2_onoff='0' and a.logtime=c.logtime then c.st1_vs1_bag2_rb else '0' END as st1_vs1_bag2_rb ,
CASE when a.st1_vs1_bag3_onoff='0' and a.logtime=c.logtime then c.st1_vs1_bag3_rb else '0' END as st1_vs1_bag3_rb ,
CASE when a.st1_vs1_bag4_onoff='0' and a.logtime=c.logtime then c.st1_vs1_bag4_rb else '0' END as st1_vs1_bag4_rb ,
CASE when a.st1_vs1_bag5_onoff='0' and a.logtime=c.logtime then c.st1_vs1_bag5_rb else '0' END as st1_vs1_bag5_rb ,
CASE when a.st1_vs1_bag6_onoff='0' and a.logtime=c.logtime then c.st1_vs1_bag6_rb else '0' END as st1_vs1_bag6_rb ,
CASE when a.st1_vs1_bag7_onoff='0' and a.logtime=c.logtime then c.st1_vs1_bag7_rb else '0' END as st1_vs1_bag7_rb ,
CASE when a.st1_vs1_bag8_onoff='0' and a.logtime=c.logtime then c.st1_vs1_bag8_rb else '0' END as st1_vs1_bag8_rb
from INDUS2_BDS.dbo.DCCT b INNER JOIN (main_vacuum_analog c inner join main_vacuum_status a on c.logtime=a.logtime) ON a.LOGTIME = b.LOGTIME
and b.beam_current LIKE '%0'
and (cast(b.beam_current as int) % 10.0 <= 0.01 OR b.beam_current % 10.0 >= 9.99)
and (cast(b.beam_current as int) >= 9.99) -- to set the lower limit of 9.99
and (cast(b.beam_current as int) <= 220.01)
and b.logtime between '2014-10-10 07:17:00' and '2014-10-10 08:46:00'
但是当我执行此查询时,我收到以下错误消息
The data types real and numeric are incompatible in the modulo operator.
我该如何解决?我想只显示附近的beam_current值,从10,20,30到220。
答案 0 :(得分:1)
我得到了答案: -
(cast(cast(b.beam_current as decimal) % 10.0 as real) <= 0.01)
and (cast(cast(b.beam_current as decimal)as real) >= 9.99) -- to set the lower limit of 9.99
and (cast(cast(b.beam_current as decimal)as real) <= 220.10)
and b.logtime between '2014-10-10 07:17:00' and '2014-10-10 08:46:00'