22,300
社区成员




declare @t table(dd numeric(38,2))
declare @i int
set @i = 1
while @i <10
begin
insert @t select -987654321098765432109876543210987654.12
set @i = @i +1
end
select * from @t
select sum(dd) sum from @t
/*
服务器: 消息 8115,级别 16,状态 2,行 10
将 expression 转换为数据类型 numeric 时发生算术溢出错误。
*/
declare @t table(dd numeric(12,2))
declare @i int
set @i = 1
while @i <10
begin
insert @t select -9876543210.12
set @i = @i +1
end
select sum(dd) sum from @t
/*
sum
----------------------------------------
-88888888891.08
*/
declare @t table(dd numeric(38,2))
declare @i int
set @i = 1
while @i <10
begin
insert @t select -98765432109876543210987654321098765432.12
set @i = @i +1
end
select sum(dd) sum from @t
/*
服务器: 消息 1007,级别 15,状态 1,行 6
数字 '98765432109876543210987654321098765432.12' 超出了数字表示范围(最大精度为 38 位有效数字)。
*/
第一条:select amount_in from stocks_inout_jz where amount_in> 0 and month_jz='2008年02月'
第二条:select sum(amount_in) from stocks_inout_jz where month_jz='2008年02月'
两句的条件不一样啊
第二条:select sum(amount_in) from stocks_inout_jz where month_jz='2008年02月'
等价于
select amount_in from stocks_inout_jz where (amount_in<= 0 or amount_In is null) and month_jz='2008年02月'