0% found this document useful (0 votes)
18 views

SQL Answers

good

Uploaded by

Aryan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

SQL Answers

good

Uploaded by

Aryan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

display Borrowers name and address that had no change in

Eligibility result only.


select bi.BorrName,
bi.BorrAddress
from
#BorrowerInfo as bi inner join
#LoanInfo1 as LI on bi.BorrID=li.BorrowerID inner join
#TestResult_Before TB on tb.loanNum = LI.LoanNum inner
join
#TestResult_After TA
on TA.LoanNum = LI.LoanNum
Where
TA.Eligibility = tb.Eligibility
display all fields in #LoanInfo that shows eligibility to FNMA in
before-case only
select LI. *
from
#LoanInfo1 as LI inner join
#TestResults_Before as TB on LI.loanNum = tb.loanmNum
where
tb.Eligibility 'FNMA'
------------------------------------------------------------display LoanNum of loans with principal balance >500K that
increased GFee
select
Li.LoanNum
from
#LoanInfo1 as Li inner join
#TestResult_After as TA on Li.LoanNum=ta.LoanNum inner join
#TestResult_Before as TB on Li.LoanNum=tb.LoanNum
where
Li.PrincipalBal>500000 and ta.GFee>tb.GFee
-------------------------------------------------------------

display the service providers info for loans that had no GFee
change.
select sp.*
from #ServiceProvider as sp inner join
#BorrowerInfo as BI on sp.ProviderID=BI.ProviderID inner
join
#LoanInfo1 as LI on LI.BorrowerID=BI.BorrID inner join
#TestResult_After as TA on LI.LoanNum = TA.LoanNum inner
join
#TestResult_Before as TB on LI.LoanNum= tb.LoanNum
where
TA.GFee=TB.GFee
---------------------------------------------------------------display loan counts of results that had changes on eligibility
and gfee; group by Eligibility.
select TA.Eligibility,
COUNT(ta.LoanNum)LoanCount
from
#TestResult_After as TA inner join
#TestResult_Before as TB on TA.LoanNum=tb.LoanNum
where
TA.Eligibility<>TB.Eligibility and TA.GFee<>TB.GFee
Group by TA.Eligibility
---------------------------------------------------------display matching (no change) counts, mismatching (with change)
counts, and total loan counts of all test result comparisons;
group by Eligibility.
Select count(LoanNum) LC,Eligibility
From
(
select TA.* from
#TestResults_Before TB inner join
#Test Results_After TA on Tb.LoanNum=TA.LoanNum
Where
Tb.Eligibility<>TA.Eligibility and Tb.Gfee<>TA.GFEE
)Tb
Group by Eligibility

You might also like