このような私のストアドプロシージャ:
ALTER procedure [dbo].[Driverperformance]
@Ecode nvarchar(50),
@startdate datetime,
@enddate datetime as
begin
SELECT e.Ecode,CAST(q.dtime AS DATE) as Date ,
e.Ename,
count(q.Ecode) CntEcode ,
count(q.DelEcode) CntDelEcode
FROM EmployeeMaster_tbl e
inner JOIN Transaction_tbl q
ON e.Ecode = q.Ecode
where q.Ecode=@Ecode
and dtime between '' + @startdate +'' and ''+@enddate+''
group by e.Ecode, e.Ename, CAST(q.dtime AS date)
ORDER BY CAST(q.dtime AS date)--e.Ecode DESC
end
私はこのように私のパラメータを渡しました:
@Ecode = 'E003' @startdate = '2013-09-03', @enddate = '2013-09-03'
このように出力されています:しかし、 cntDelEcode が間違っています.(私は適切な DelEcode の数を取得していません)ので、ストアドプロシージャで変更する必要があるもの)
CntEcode のカウントを確認するために、次のようなクエリを書きます。
select * from Transaction_tbl where dtime >='2013-09-03 00:00:00.000' and dtime <='2013-09-03 23:59:59.000' and Ecode='E003'
. 今、私は27行を取得しています。したがって、私のcntEcodeカウントが正しいことを理解しました。CntDelEcode のカウントを確認するために、次のようなクエリを書きます。
select * from Transaction_tbl where dtime >='2013-09-03 00:00:00.000' and dtime <='2013-09-03 23:59:59.000' and DelEcode='E003'
今、私は35行を取得しています..しかし、ストアドプロシージャを実行している間、35行を取得するのに23行しか取得していません..ストアドプロシージャがどこで間違ったのですか? 調べるのを手伝ってください