Hi All,
I have written the query like this::
select
B.PaymentId
,B.PayDate
,case when (B.PayFrom) is Null
Then
(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
Then
(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'))
End
,B.MonerisMsg
,B.GuardianId
,B.RegId
,B.TransId
,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?