SQLTeam.com | Weblogs | Forums

Sub Query Not Cooperating

#1

Hello.

I am new to sub queries and need some assistance getting this to work.

Here is my statement and I am getting a Msg 102, Level 15, State 1, Line 7
Incorrect syntax near 'lp' message in SQL Server Management

Select
ln.MemberNumber,
ln.LoanNumber,
ln.OpenDate,
ln.OriginalAmount,
ln.Balance,
VehicleVIN = (Select lp.ItemName From Loan LoanProperty lp Where lp.MemberNumber=ln.MemberNumber)

From
Loan ln

Where
ln.LoanType In ('7','27','42','43','1','4','45','47')

#2

Solved

Select
ln.MemberNumber,
ln.LoanNumber,
ln.OpenDate,
ln.OriginalAmount,
ln.Balance,
VehicleVIN = (Select lp.ItemName From LoanProperty lp Where lp.MemberNumber=ln.MemberNumber AND lp.LoanNumber=ln.LoanNumber)

From
Loan ln

Where
ln.LoanType In ('7','27','42','43','1','4','45','47')