-1

前三个算术函数工作

select CreditLimit,'sum'=CreditLimit+Zip from Customers

select CreditLimit,'sub'=CreditLimit-Zip from Customers

select CreditLimit,'div'=CreditLimit/Zip from Customers

最后两个算术函数或不工作显示错误

select CreditLimit,'mod'=CreditLimit%Zip from Customers

ERROR DISPALY: Arithmetic overflow error converting expression to data type smallmoney.

select CreditLimit,'mul'=CreditLimit*Zip from Customers

ERROR DISPALY:The data types smallmoney and nchar are incompatible in the modulo operator.

提前谢谢朋友!

4

1 回答 1

0

我怀疑该列ZIP是一种nchar数据类型。您需要smallmoney在执行算术运算之前将其转换为

select CreditLimit,'mod'=CreditLimit%convert(smallmoney,Zip) from Customers
于 2013-01-04T05:21:37.857 回答