sql server - Subquery returned more than 1 value while executing stored procedure -
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 , ( select count(*) transaction_tbl dtime >= '' + @date1 + '' , dtime <= '' + @date2 + '' , delecode = @ecode group cast(dtime date) ) employeemaster_tbl e join transaction_tbl q on e.ecode = q.ecode q.ecode = @ecode , dtime >= '' + @date1 + '' , dtime <= '' + @date2 + '' group e.ecode , e.ename , cast(q.dtime date) order cast(q.dtime date) end
while executing query getting error this:
subquery returned more 1 value. not permitted when subquery follows =, !=, <, <= , >, >= or when subquery used expression.
in query have :
( select count(*) transaction_tbl dtime >= '' + @date1 + '' , dtime <= '' + @date2 + '' , delecode = @ecode group cast(dtime date) )
as column. above because of group return more 1 rows each row of select. not posible in sql.
Comments
Post a Comment