Declare @Amt
Declare @Reb
select @Amt = Amt,isnull(Amt,0) as Amt,@Reb = Reb,isnul(Reb,0) as Reb from R where id = '1010101' and name = 'GT'
print @Amt
print @Reb
然后就出错了,请问怎么改正? ------最佳解决方案--------------------
SELECT @Amt1 = ISNULL(Amt, 0) ,
@Reb1 = ISNULL(Reb, 0)
FROM R
WHERE id = '10001'
SELECT @Amt2 = ISNULL(Amt, 0) ,
@Reb2 = ISNULL(Reb, 0)
FROM R
WHERE id = '10002'
SELECT @Amt3 = ISNULL(Amt, 0) ,
@Reb3 = ISNULL(Reb, 0)
FROM R
WHERE id = '10003'
SELECT @Amt4 = ISNULL(Amt, 0) ,
@Reb4 = ISNULL(Reb, 0)
FROM R
WHERE id = '10004'
SELECT @Amt1 + @Amt2 + @Amt3 + @Amt4