以下は私のストアドプロシージャです
ALTER PROCEDURE [aaa].[sp_getabc] (
@fromdate smalldatetime,
@todate smalldatetime)
AS
BEGIN
SET NOCOUNT ON;
declare @tmp1 as int
declare @tmp2 as int
declare @sum as int
declare @tmp3 as int
select @tmp1 = (select count(*) as decdbo from abc where AppID IN (108,104,113,110,218,171) and Status IN ('T','L') and calldate between @fromdate and @todate)
select @tmp2 = (select count(*) as decauto from abc where AppID IN (278,283) and Status IN ('T','L') and calldate between @fromdate and @todate)
select @sum = @tmp1 + @tmp2
select @tmp3 = (select SUM(Duration)/60 as DecemberLastWeek from abc where dnis = '6503533019' and calldate between @fromdate and @todate)
select @tmp3 as Duration , @sum as Transcriptions , @sum/@tmp3 as TransPerMin
END
ストアドプロシージャとしてではなくステートメントを実行すると正しい値が得られますが、ストアドプロシージャを実行すると、@tmp3と@sum / @ tmp3でNULLが得られませんが、@sumの値も間違っています。問題はどこにありますか。ありがとうございました