Skip to Content
0
Former Member
Jul 30, 2014 at 07:05 AM

Case in Query

18 Views

Hi All,

I need to consider a case in the below mentioned query i.e where sum(OpenBal) is null, consider sum(doctotal) else sum(OpenBal).

SELECT T0.[CardCode], T0.[CardName],

isnull((Select sum (openbal) from ORCT inner join NNM1 on ORCT.Series = NNM1.Series

where cardcode = T0.Cardcode and NNM1.SeriesName like 'Deposit%' and JrnlMemo not like 'cancel%' ),0) as 'Security'

FROM [dbo].[OCRD] T0

where T0.[CreditLine] > '0.00'

Any suggestions?

Thanks,

Joseph