June 4, 2004 at 8:59 am
select
BORR.fico as borr1fico,
BORR2.fico as borr2fico,
BORR3.fico as borr3fico
from tblloan EX with (nolock)
inner join borrower BORR with (nolock) on BORR.Id = EX.ApplId
left outer join borrower BORR2 with (nolock) on BORR2.Borr_Id = EX.LoanApplId and BORR2.Borr_Id = '2'
left outer join borrower BORR3 with (nolock) on BORR3.Borr_Id = EX.LoanApplId and BORR3.Borr_Id = '3'
where EX.ApplId = '1234567890'
and BORR.Borr_Id = '1'
Hi,
I would like to left outer join on a table that is on the right side of a left outer join.
For ex, I have a join between the export and borrower table (1:M). I would like to add another outer join
to a borrower_address table from the borrower table, but I am not sure how to accomplish this. An example
of the end result I a looking for would be:
borr1fico borr2fico borr3fico borr1street borr1city borr1state borr2street borr2city borr2state
--------
700 650 800 113 Elm Mpls MN 504 Oak StPaul null
Andrew J. Hahn
June 7, 2004 at 4:09 am
Try using a temporary table and join that to the address table.
Eg
DROP TABLE #TEMP_BORR
Hope that helps.
Don.
June 7, 2004 at 6:50 am
select
BORR.fico as borr1fico,
BORR2.fico as borr2fico,
BORR3.fico as borr3fico,
a1.street as borr1street,
a1.city as borr1city,
a1.state as borr1state,
a2.street as borr2street,
a2.city as borr2city,
a2.state as borr2state,
a3.street as borr3street,
a3.city as borr3city,
a3.state as borr3state
from tblloan EX with (nolock)
inner join borrower BORR with (nolock) on BORR.Id = EX.ApplId
left outer join address a1 on a1.Id = BORR.Id
left outer join borrower BORR2 with (nolock) on BORR2.Borr_Id = EX.LoanApplId and BORR2.Borr_Id = '2'
left outer join address a2 on a2.Id = BORR2.Id
left outer join borrower BORR3 with (nolock) on BORR3.Borr_Id = EX.LoanApplId and BORR3.Borr_Id = '3'
left outer join address a3 on a3.Id = BORR3.Id
where EX.ApplId = '1234567890'
and BORR.Borr_Id = '1'
If this not right, can you post the ddl of the tables.
Far away is close at hand in the images of elsewhere.
Anon.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply