January 6, 2012 at 10:45 am
I have the following query and it works
I would like to rewrite this query as an outer join but i donot know how. I wouild like help in rewriting the query.
Basically, i just want to return records that do not exists in
F47FirmCommitment but do exists in mf_insured_loan.
select distinct fk_fha_number,mf_insured_loan.date_firm_commitment
from mf_insured_loan, F47FirmCommitment
where (fk_fha_number <> FHACaseNumber)
and mf_insured_loan.date_firm_commitment is null
Thanks in advance
January 6, 2012 at 10:59 am
Try this:
SELECT DISTINCT T1.fk_fha_number
,T1.date_firm_commitment
FROM mf_insured_loan T1
LEFT JOIN F47FirmCommitment T2
ON T1.fk_fha_number = T2.FHACaseNumber
WHERE T1.date_firm_commitment is null
AND T2.fk_fha_number IS NULL
January 6, 2012 at 10:02 pm
Check out EXCEPT.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 7, 2012 at 4:01 am
This should work too.
SELECT mil.date_firm_commitment
, mil.fk_fha_number
FROM mf_insured_loan mil
WHERE NOT EXISTS (
SELECT *
FROM F47FirmCommitment FC
WHERE FC.FHACaseNumber = mil.fk_fha_number
)
January 8, 2012 at 10:21 am
zwheeler (1/6/2012)
I have the following query and it worksI would like to rewrite this query as an outer join but i donot know how. I wouild like help in rewriting the query.
Basically, i just want to return records that do not exists in
F47FirmCommitment but do exists in mf_insured_loan.
select distinct fk_fha_number,mf_insured_loan.date_firm_commitment
from mf_insured_loan, F47FirmCommitment
where (fk_fha_number <> FHACaseNumber)
and mf_insured_loan.date_firm_commitment is null
Thanks in advance
Be careful about this. Although the query will produce a result set (a filtered cross join), it certainly won't provide anything resembling your stated requirement - which is what folks will read into it. Better to say "this query executes but the results are not what I'm looking for".
For better assistance in answering your questions, please read this[/url].
Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply