Hi Peter -
I'm as sure as I can be that the choice of representation for dates is not
the issue. I'm simply comparing some strings that happen to encode some dates
in YYYY-MM-DD format. ANd I know that the rows in question have valid data
because I've looked and because the inclusion of a simple WHERE clause shows
the comparisons to be working as expected.
Please understand that I'm NOT saying that the JOIN condition fails for
certain rows. I'm saying that the JOIN is seemingly not even being ATTEMPTED
for certain rows.
Here's what I expected from the LEFT JOIN:
Rbt Row 1 + [FullDWGPP row x | null]
Rbt Row 2 + [FullDWGPP row y| null]
Rbt Row 3 + [FullDWGPP row z | null]
...
The success or failure of the JOIN conditions (including the date
comparisons) would determine whether the right side of the resulting row is
a) FullDWGPP data or b) null but should have no bearing on the presence or
absence of rows themselves.
Here's what I get, though:
Rbt Row 1 + FullDWGPP row x
Rbt Row 3 + FullDWGPP row z
Rbt Row 2 is missing from the result set entirely. If I add the WHERE
clause, without changing anything else, I get:
Rbt Row 2 + FullDWGPP row y
Pete
:
Hello,
It seems string comparison is a little different from date comparison. You
may want to convert the text to date by using CVDate/left/mid/right
functions before comparision.
Also, make sure the string format is consistent for the omitted records.
Best Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Thread-Topic: Left Join Not Properly
thread-index: AcZUF55aEEUGlOEqRY+dqR1MIL7Nww==
X-WBNR-Posting-Host: 12.108.117.125
From: =?Utf-8?B?UGV0ZQ==?= <
[email protected]>
References: <
[email protected]>
<
[email protected]>
Subject: RE: Left Join Not Properly
Date: Thu, 30 Mar 2006 08:33:04 -0800
Lines: 43
Message-ID: <
[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
Newsgroups: microsoft.public.access.queries
Path: TK2MSFTNGXA01.phx.gbl
Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.access.queries:274451
NNTP-Posting-Host: TK2MSFTNGXA01.phx.gbl 10.40.2.250
X-Tomcat-NG: microsoft.public.access.queries
A worthy thought, but ...
Because of some other limitations, all dates are defined as 10-character
text fields in DB2's date format (YYYY_MM_DD). IOW, they're string
variables,
not date/time variables.
This works for the 50,000+ rows where the join condition is satisfied. And
it works for all but some of the cases where the join condition is not
satisfied. And it works when I add the WHERE clause for any of the groups
that are being omitted from the result set.
:
You appear to be comparing dates using a >= and <= and that may not work
depending on the format and definition of the date columns.
-Dorian
:
I'm joining two tables using left join and noticed that some (but not
all) of
the rows from the left table were being excluded from the result set
when the
join condition is not satisfied. The following SQL returns one row, as
it
should:
SELECT Rbt.*, FullDWGPP.*
FROM Rbt LEFT JOIN FullDWGPP ON
Rbt.BILL_MO >= FullDWGPP.ROW_BEG_DT
AND Rbt.BILL_MO >= FullDWGPP.CSPI_EFF_DT
AND Rbt.BILL_MO <= FullDWGPP.ROW_END_DT
AND Rbt.BILL_MO <= FullDWGPP.CSPI_TERM_DT
AND Rbt.GROUP = FullDWGPP.GRGR_ID
AND Rbt.SUB_GROUP = FullDWGPP.SGSG_ID
AND Rbt.PLAN_CD = MID(FullDWGPP.PDPD_ID,4,4)
WHERE Rbt.GROUP = '00500530';
If I remove the WHERE clause, the same SQL returns many rows, but the
row
for group '00500530' is not amongst them. Tried all manner of
parenthesis but