select sum(namount)-(@inta+@intb)) as sscommisoin, (@inta+@intb) as commisoin ,sum(namount) allnamount,invoice_no
from pcinvoicedetail with(nolock) where invoice_no=@invoiceno group by invoice_no@inta=0 @intb=760,在运行时(@inta+@intb) as commisoin竟等于空,为什么会为空,之前写在存储过程还好好的。请高手指点,谢谢!
from pcinvoicedetail with(nolock) where invoice_no=@invoiceno group by invoice_no@inta=0 @intb=760,在运行时(@inta+@intb) as commisoin竟等于空,为什么会为空,之前写在存储过程还好好的。请高手指点,谢谢!
如果@inta,@intb是作为传入参数,并再传出的话,是要output参数的.
select @intb=0
或者给个初始值.
null+0得到的是null
null+'ss'得到的也是null
select @inta = isnull(@inta,0)
if @inta=null
begin
select @inta=0
end
还是如此,这种现象很突然,之前并没有这种现象。
if @inta = null --这个地方不能用=,得用 is
begin
select @inta=0
end
谢谢终于3裤衩了
THANK YOU~~~~~~~~~~~~~~
然後改成這樣
select sum(namount)-(isnull(@inta,0)+ isnull(@intb,0)) as sscommisoin, (isnull(@inta,0)+ isnull(@intb,0)) as commisoin ,sum(namount) allnamount,invoice_no
from pcinvoicedetail with(nolock) where invoice_no=@invoiceno group by invoice_no
加上ISNULL后这个问题便迎刃而解。
谢谢两位!