>select max(cClient_Account_Number) as cClient_Account_Number, ; > min(TR.cTrans_Relateds_Pk) as cTrans_Relateds_Pk, ; > count(*) as cntGuarantors from Trans inner join Trans_Relateds TR on ; > Trans.cTrans_pk = TR.cTrans_fk ; > where TR.iGuarantor_flag = 1 and TR.iPrimary_flag = 0 ; > group by Trans.cTrans_pk having cntGuarantors = 1 ; > into cursor curProblems>
select cClient_Account_Number, ; cTrans_Relateds_Pk from Trans ; inner join Trans_Relateds TR on ; Trans.cTrans_pk = TR.cTrans_fk where cTrans_pk ; in (select cTrans_pk, count(*) as cntGuarantors ; from Trans inner join Trans_Relateds TR on ; Trans.cTrans_pk = TR.cTrans_fk ; group by Trans.cTrans_pk having cntGuarantors = 1) ; where TR.iGuarantor_flag = 1 and TR.iPrimary_flag = 0 ; into cursor curProblemsDo you have a better idea?