reporting services - Microsoft Report Builder TSQL query issue -
i have written following tsql query , running within microsoft report builder. issue 1 portion not working correctly. information helpful. thanks.
- note - (select processdate ufnarcugetlatestprocessdate()) returns date query being run on. it's 1 of our standard functions.
this part having issues with. reason not finding loans have null close date. example account testing on has open loan yet value returning 0 when should receive 1. see missing?
(select count(*) -- check if there no open loans arcu.vwarculoan l a.accountnumber=l.accountnumber , l.processdate = (select processdate ufnarcugetlatestprocessdate()) , l.loanclosedate not null)=0 , -- end check if there no open loans
below whole query.
select a.accountnumber 'account number' ,a.accountbranch 'branch number' ,a.accountopendate 'account open date' ,a.accountactivitydate 'last activity date' ,n.namefirst+' '+n.namelast 'member name' arcu.vwarcuaccount left outer join arcu.vwarcuname n on a.accountnumber = n.accountnumber a.processdate = (select processdate ufnarcugetlatestprocessdate()) , a.accountclosedate null , a.accountopendate>dateadd(day,-30,a.accountopendate) , n.nametype=0 , n.processdate = (select processdate ufnarcugetlatestprocessdate()) , (select sum(s.sharebalance) -- check if shares 0 arcu.vwarcushare s a.accountnumber=s.accountnumber , s.processdate = (select processdate ufnarcugetlatestprocessdate()) , a.processdate = (select processdate ufnarcugetlatestprocessdate()))=0 , -- end check if shares 0 (select count(*) -- check if there no open loans arcu.vwarculoan l a.accountnumber=l.accountnumber , l.processdate = (select processdate ufnarcugetlatestprocessdate()) , a.processdate = (select processdate ufnarcugetlatestprocessdate()) , l.loanclosedate not null)=0 , -- end check if there no open loans (select count(*) --check if tracking records exist arcu.vwarculoantracking t a.accountnumber=t.accountnumber , t.processdate = (select processdate ufnarcugetlatestprocessdate()) , a.processdate = (select processdate ufnarcugetlatestprocessdate()) , t.loantrackingtype in(@trackingtypes) )=0 , --end check if tracking records exist (select count(*) arcu.vwarcuinventory a.accountnumber=i.inventoryaccountnumber , i.processdate = (select processdate ufnarcugetlatestprocessdate()) , a.processdate = (select processdate ufnarcugetlatestprocessdate()) , i.inventorystatus=2 , i.inventorytype in (@inventorytype))=0 order a.accountnumber
i'm assuming if loan still "open" l.loanclosedate null.
in case problem query
l.loanclosedate not null
this criteria means counting closed loans, i.e. loans have value in loancloseddate. appear need inverse of that, i.e. open loans. need change criteria
l.loanclosedate null
so counting open loans.
Comments
Post a Comment