Solved

Access - Match on more than one row

Posted on 2011-03-07
10
293 Views
Last Modified: 2012-08-13
Hi,

In the attached file, please offer a solution as to how I can get a list joined on the A10 and B10, where A9 and B9 are unequal. If it is a one to many pairing, this is viewed as not a match, but it really is not.

Thank you.
Unequal-Map.xlsx
0
Comment
Question by:tahirih
  • 7
  • 2
10 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35061051
You may want to click the "Request Attention" link and ask that the SQL Syntax zone be added to this Q.
0
 
LVL 77

Expert Comment

by:peter57r
ID: 35061079
Don't really follow and I don't know what you are referring to by 'A10' and 'A9'as there doesn't appear be anything with those labels.
0
 

Author Comment

by:tahirih
ID: 35061278
Sorry, yes, I had posted the wrong file, please post an updated one, with the proper field names.

It is easy to create a query where A9 = B9 and A10 = B10.

What I am looking for is where A10 = B10, but A9 <> B9.

Hope this helps.

Unequal-Map.xlsx
0
 

Author Comment

by:tahirih
ID: 35061485
Here is the actual code I am using:

SELECT DISTINCTROW [I9 DX].[ICD-9 Dx Code], [I9 DX].[ICD-10 Dx Code], [I10 DX].[ICD-10 Dx Code], [I10 DX].[ICD-9 Dx Code]
FROM [I9 DX] INNER JOIN [I10 DX] ON [I9 DX].[ICD-10 Dx Code] = [I10 DX].[ICD-10 Dx Code]
GROUP BY [I9 DX].[ICD-9 Dx Code], [I9 DX].[ICD-10 Dx Code], [I10 DX].[ICD-10 Dx Code], [I10 DX].[ICD-9 Dx Code];
0
 

Author Comment

by:tahirih
ID: 35061496
Here is the story, and the desired outcome. I have two tables, that have two fields ICD-9 Dx Code and ICD-10 Dx Code in each table (I9 and I10). I am joining on ICD-10 Dx Code, and want to receive a table where the ICD-9 Dx Codes are not the same from I9 to I10 (that is the pairing ot the ICD-10 Dx Code value changes).

The problem is, one I9 code can be mapped to more than one I10, and vice versa. Therefore, when I code, Access/SQL views this as an unequal match, but all that really happens is that there are multiple rows (hope this makes sense).
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:tahirih
ID: 35061510
The main issue is sorting on the fields so that the code captures that there may be a match on different rows per the I10 match.
0
 

Author Comment

by:tahirih
ID: 35061550
Here is a simple parallel:

Table A
Color       Number
Red          1
Red          2
Blue         3
Orange    4

Table B
Color       Number
Red        1
Red        2
Red       20
Blue       3
Blue       30
Orange   4

Expected Output
Color Number
Red    20
Blue 30
Orange 4

Unfortunately, since this is a one to many in values that are in both tables, this code reads this as Red 1 and Red 2 are also not equal, but they are.

The objective is to output a table where when Table 1 and Table 2 are joined on color, the output table only contains Numbers that are not equal for the join on color in Tables 1 and 2.

Hope this helps.

Thanks

0
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 35061658
Do you mean that you want records from table B which are not in table A?

Select B.* from tableB as B left join tableA as A
on B.Color= A.Color and B.[Number] = a.[Number]
where A.color is null
0
 

Author Comment

by:tahirih
ID: 35061782
A blend of both, I have actually used Left and Right joins after my last posting and prior to your last post.

Let me review my work, but yes, you are right, this is a Left/Right Join question.

Thank you
0
 

Author Closing Comment

by:tahirih
ID: 35062382
Thank you.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now