Link to home
Start Free TrialLog in
Avatar of btl2008
btl2008

asked on

Need view to compare Muliple rows in table 1 to multiple rows in table 2 and give one result

I have two tables. One table contains records where a unique item (x) may associate with several bits. I have another table which assoicates thost bits with a seperate unique code (x'). For example:

tbl1                 tbl2
a 1                  x  1
a 2                  x  2
a 3                  y 1
a 4                  y 2
a 5                  y 3
b 1
b 2
c 1
c 2
c 3
What I'd like to have is a veiw that tells me x is a b because of its combination and y is a c because of its combination, but niether are a because of the required combination. I haven't been able to figure out how to put the view together and I'm hoping it's just a mental margarita on my part. Any ideas?
ASKER CERTIFIED SOLUTION
Avatar of chapmandew
chapmandew
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That was actually the first time I'd used  checksum_agg
Avatar of btl2008
btl2008

ASKER

That's a nifty way of doing it that I haven't seen before. The problem is the actual data in question are all string fields.
Avatar of btl2008

ASKER

I probably put a bad example in the inital question. Here's a more realistic situation:

tbl1 has multiple Orders. Each Order has mulitple Samples. Each sample has multiple tests defined by a unique three field combination, so a row in table one looks like:

tbl1
Order  Sample     Group     Test   Method
1234   1234-001  Group1  Test1 Method1
1234   1234-001  Group1  Test2 Method1  

tbl2 defines our billing code for combinations of test and method. Some test/methods are grouped together for billing purpose, so we get something like

tbl2
TestCode  Group     Test   Method
A1             Group1  Test1 Method1
A2             Group1  Test1 Method1
A2             Group1  Test2 Method1


In this situation, order 1234 needs to be billed out as 1 A2. The structure of tbl1 is set, but if needed I can change the way tbl2 is set up. Sorry for the confusion. Is this possible?