morechocolate
Technical User
I am getting the following error after adding in the subquery.
The following are views
nyl_property_opstatmt
nyl_property_appr
nyl_loanxref
select distinct fl.loan_xref,sum(distinct isnull(po.noi,0)),
isnull((sum(distinct po.noi) * max(isnull(ex.nyl_part_per,100)))/100,0),
max(po.user_def_type)
from nyl_loanxref lx
inner join extgeneral ex on ex.loan = lx.loan
inner join loancoll lc on lc.loan = lx.loan
inner join fnUserDefType() fl on fl.loan_xref = lx.loan_xref
right outer join nyl_property_opstatmt po on po.prop_code = lc.code
where (count_type < 2 or
(po.user_def_type = 'actual' or
(lc.loan not in (select a.loan
from nyl_loanxref r
inner join fnUserDefType() d on r.loan_xref = d.loan_xref
right outer join nyl_property_appr a on a.loan = r.loan
right outer join nyl_property_opstatmt o on o.prop_code = a.prop_code
where o.user_def_type = 'actual' and
d.count_type > 1 and
lc.loan = a.loan and
d.loan_xref = fl.loan_xref and
po.prop_code = a.prop_code
))))
group by fl.loan_xref
The following are views
nyl_property_opstatmt
nyl_property_appr
nyl_loanxref
select distinct fl.loan_xref,sum(distinct isnull(po.noi,0)),
isnull((sum(distinct po.noi) * max(isnull(ex.nyl_part_per,100)))/100,0),
max(po.user_def_type)
from nyl_loanxref lx
inner join extgeneral ex on ex.loan = lx.loan
inner join loancoll lc on lc.loan = lx.loan
inner join fnUserDefType() fl on fl.loan_xref = lx.loan_xref
right outer join nyl_property_opstatmt po on po.prop_code = lc.code
where (count_type < 2 or
(po.user_def_type = 'actual' or
(lc.loan not in (select a.loan
from nyl_loanxref r
inner join fnUserDefType() d on r.loan_xref = d.loan_xref
right outer join nyl_property_appr a on a.loan = r.loan
right outer join nyl_property_opstatmt o on o.prop_code = a.prop_code
where o.user_def_type = 'actual' and
d.count_type > 1 and
lc.loan = a.loan and
d.loan_xref = fl.loan_xref and
po.prop_code = a.prop_code
))))
group by fl.loan_xref