I have written the query like this::
,case when (B.PayFrom) is Null
(select G.E_FName+ ' '+G.E_LName from LakesideLabSQL.dbo.tblGuardian G join LakesideLabSQL.dbo.tblUserPayment
H on G.GuardianId=H.GuardianId where H.PayDate>'2013-04-02' and H.PayDate<DATEADD(day,1,'2013-04-2'))
when (B.GuardianId) IS Null
(select I.FirstName+' '+I.LastName from LakesideLabSQL.dbo.tblUserPayment K join LakesideLabSQL.dbo.tblUser I
on K.PayFrom=I.UserId where K.PayDate>'2013-04-02' and K.PayDate<DATEADD(day,1,'2013-04-2'))
,B.PayAmount as Amount
,B.Status as PayStatus
,Null as CardAuthorizationCode
,B.CnfCode as Event
from LakesideLabSQL.dbo.tblUserPayment B
join LakesideLabSQL.dbo.tblUser D on D.UserId=B.PayFrom
where B.PayDate>'2013-04-02' and B.PayDate<DATEADD(day,1,'2013-04-2')
But its throwing the error for me in Case part.The error is "subquery is returned more than 1 value.
This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Can you please tell me the solution how to make this work?