I am trying to run following query, it runs fine but not giving me the correct results back, if someone can please check this case stmt and let me know where the problem is, i want "then" within case stmt to return [24], which i am using in select, select [24], [24] is a field/column name, I can take out the select from case stmt and run seperatley and it runs fine....
select CONVERT(numeric(10), m.acct) as CUSTNUM, m.branch as AORGID, l.sub as PRODID,
l.code as ALNTYPE,
case when exists (select [24]
from
(
select joinfield = datename(m, opened) + cast(year(opened) as varchar(4)), *
from loan
) a
inner join
(
select joinfield = datename(m, date1) + cast(year(date1) as varchar(4)), *
from FHLB
) b on a.joinfield = b.joinfield) then '[24]' else 'norate' end as FTPRATE
from memb m
INNER JOIN loan l on m.rowno = l.rowno_membloan_memb
INNER JOIN lohi h on l.rowno = h.rowno_loanlohi_loan
and m.acct = 11407
where l.status not in ('closed','delinquent','wr
iteoff','c
ancelled')
group by m.acct,m.branch,l.sub,l.co
de
results,
FTPRATE column just coming back as [24],...
Start Free Trial