• With the following assumptions I am trying to answer the nikels question ,

    Accounts table is some thing like

    
    
    Cretate table Accounts
    (
    acccountid int ,
    cc_type varchar(2) ,
    ……..
    )

    and credit card table

    
    
    create creditcard
    (
    accountid int ,
    ccnumber varchar(50)
    )

    Here I am trying to use much under explored area of sub quires

    
    
    Select A.accountid,A.cc_type,
    cc_no_or_dc_no
    =case when cc_type=’cc’ then
    ( select cc_no from creditcard B where A.accountid=B.accountid)
    when cc_type=’dc’ then
    ( select dc_no from debitcard B where A.accountid=B.accountid)
    else ‘No more credit’
    end
    From
    Accounts A

    I think this will solve his problem ,just for showing other credit methods are possible I added one more debitcard table ,This method will reduce no matches in the query

    With best

    Regards

    John