Use distinct on one column but want 2 columns of data returned
- From: elittle <elittle@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 1 Nov 2007 14:36:02 -0700
Thank you in advance for any and all assistance. I am trying to do a
comparison of 2 tables and I am expecting the result to be what ever is not
in one of the tables. The table I need the result from has 2 columns of data
that I want returned based on col1 being distinct because I know it has
duplicates in it.
Ex. TableA: Col1, Col2 I want my result to have both columns of data based
on Col1 being distinct
TableB: Col3
I compare TableA.Col1 to TableB.Col3 whatever is NOT in TableB but is in
TableA should be in the result.
I have tried this query:
Select distinct TableA.Col1,TableA.Col2
From TableALeft Join TableB ON Table.Col1 = TableB.Col3
Where TableB is Null
The result I get has duplicates.
I have also tried this query:
Select distinct TableA.Col1,TableA.Col2
From TableAWhere Not Exists
(
Select *
From TableBWhere TableA.Col1 = TableB.Col3
)
Again the result contains duplicate data. Can anyone clarify forme what I
am doing wrong?
Thanks,
Erik
.
- Follow-Ups:
- Re: Use distinct on one column but want 2 columns of data returned
- From: Russell Fields
- Re: Use distinct on one column but want 2 columns of data returned
- Next by Date: Re: Use distinct on one column but want 2 columns of data returned
- Next by thread: Re: Use distinct on one column but want 2 columns of data returned
- Index(es):
Relevant Pages
|
|