我有一个这样的存储过程:
ALTER procedure [dbo].[Driverperformance]
@Ecode nvarchar(50),
@startdate datetime,
@enddate datetime
as
begin
declare @date1 datetime = CONVERT(datetime, @startdate + ' 00:01:00.000', 120);
declare @date2 datetime = CONVERT(datetime, @enddate + ' 23:23:59.000', 120);
SELECT
e.Ecode,CAST(q.dtime AS DATE) as Date,
e.Ename,
count(q.Ecode) CntEcode ,
count(DelEcode) CntDelEcode
FROM EmployeeMaster_tbl e
inner JOIN Transaction_tbl q
ON e.Ecode = q.Ecode where q.Ecode=@Ecode
and dtime between '' + @date1 +'' and ''+@date2+''
group by
e.Ecode,
e.Ename,
CAST(q.dtime AS date)
ORDER BY CAST(q.dtime AS date)--e.Ecode DESC
end
但我没有得到正确的 DelEcode 计数,当我像这样检查 DelEcode 的计数时,我的存储过程有什么问题:select * from Transaction_tbl where dtime >='2013-09-03 00:00:00.000' and dtime < ='2013-09-03 23:59:59.000' 和 DelEcode='E003' 得到 35 行,但在执行存储过程时只得到 23 个 CntDelEcode