You are on page 1of 2

select COUNT(*) from loan l

join Smdf02a s on l.loannum=s.loannum


where CAST(NoteRate as CHAR)<>notrat
select COUNT(*) from Loan l
join loanStatus Ls on L.LoanNum=Ls.LoanNum
join Branch B on L.BranchNum=B.BranchNum
Where B.DivType='CLD' and cast(year(LS.FunDtTm) as varchar)=
'2007'
select COUNT(L.LoanNum) DivType from Loan L
join LoanStatus LS on L.LoanNum=LS.LoanNum
join Branch B on L.BranchNum=B.BranchNum
Group by DivType
Select COUNT(L.LoanNum) from Loan L
inner join LoanStatus LS ON L.LoanNum=LS.LoanNum
inner join Branch B ON L.BranchNum=B.BranchNum
Where B.DivType in ('CLD','WLD') and cast(year(LS.FunDtTm) as
varchar)='2007' and
cast(Month(LS.FunDtTm) as varchar)='January' and L.NoteRate >=7
Select COUNT(*),L.LoanNum from Loan L
inner join LoanStatus LS ON L.LoanNum=LS.LoanNum
inner join Branch B ON L.BranchNum=B.BranchNum
Where B.DivType in ('CLD','WLD') and cast(year(LS.FunDtTm) as
varchar)='2007' and
cast(Month(LS.FunDtTm) as varchar)='January' and L.NoteRate >=7
Group by L.Loannum
Having COUNT(*)>1000

Loan
Column
LoanNum
BranchNum
NoteRate
LoanStatus
Column
LoanNum
FundDtTm
Smdlf02a
Column
LoanNum
notrat
Branch
Column
BranchNum
DivType
BranchNam
e

Data
Type
Int
Int
Real

Description
Loan Number
Branch Number
Note Rate

Data
Description
Type
Int
Loan Number
Smalldatet Funded Date
ime
Data
Type
Int
Char(7)

Description

Data
Type
Int
Char(3)

Description

Char(40)

Loan Number
Note Rate

Branch Number
Division Type (CMD, CLD, WLD,
etc.)
Branch Name

1. Write a query to find number of loans where NoteRate IS NOT EQUAL


to notrat.
2. Write a query to find number of CLD loans which were funded this
year (2007).
3. Write a query to find number of loans which were funded this year
by every Division Type
4. Write a query to list CLD and WLD loans which were funded in
January of 2007 with Note Rate of at least 7.0. (List them by
LoanNum in descending order)
5. Write a query to list branches which have more than 1000 loans that
were funded in January of 2007 with Note Rate of at least 7.0.

You might also like