sql server - while taking count of two column result is not showing proper -
i have stored procedure this:
alter procedure [dbo].[driverperformance] @ecode nvarchar(50), @startdate datetime, @enddate datetime 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 date) date, e.ename, count(q.ecode) cntecode , count(delecode) cntdelecode employeemaster_tbl e inner join transaction_tbl q on e.ecode = q.ecode q.ecode=@ecode , dtime between '' + @date1 +'' , ''+@date2+'' group e.ecode, e.ename, cast(q.dtime date) order cast(q.dtime date)--e.ecode desc end
but not getting count of delecode proper ,what wrong stored procedure while checking count of delecode this:select * transaction_tbl dtime >='2013-09-03 00:00:00.000' , dtime <='2013-09-03 23:59:59.000' , delecode='e003' getting 35 rows,but while executing store procedure getting 23 counts of cntdelecode
if want count number of different "delecode" try count(distinct delecode). if not, going count number of records not null delecode values. if perform join count result of cartesian product, not number of different delecodes.
Comments
Post a Comment