CASE Statement with Exists

Database

CASE Statement with Exists

Can anyone help me understand how to fix this:

 

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 3951 StartFragment: 314 EndFragment: 3919 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet

select v.acctno,CASE when exists (select v.acctno from VPILOT_MTS.MDM_ME_Vw v
join vpilot_mts_ML.mutualfundc_vw c
on v.acctno = c.account_id
where V.acct_Opn = 'Y'
and  Acct_LOB_Chnl in ('FFF','MMM')) then 'Y' Else 'N' END
from VPILOT_MTS.MDM_ME_Vw v
3 REPLIES
Teradata Employee

Re: CASE Statement with Exists

select v.acctno,
CASE when V.acct_Opn = 'Y' and  c.Acct_LOB_Chnl in ('FFF','MMM'))
    then 'Y' Else 'N' END
from VPILOT_MTS.MDM_ME_Vw v
left outer join vpilot_mts_ML.mutualfundc_vw c
    on v.acctno = c.account_id

 

I'm guessing .Acct_LOB_Chnl is in vpilot_mts_ML.mutualfundc_vw; otherwise I see no reason to even do the join.

Re: CASE Statement with Exists

Thanks- I am trying to also check that the account_id exists mutualfundc_vw as part of the of Case statement.  This doesnt necessarily do that does it?

Teradata Employee

Re: CASE Statement with Exists

If it does not exist then c.Acct_LOB_Chnl will be null, and the CASE will return 'N'.