Hi,
Sorry I was not clear... hope this helps...
1. The table has NO primary key and is composed of the following...
2. There are combinations of Orders (Ord) and Invoices (Inv)
3. There are Freight Bill numbers (FrtKey)
The same FryKey may appear on many combinations of Ord + Inv
There may be several instances of Ord + Inv with different FrtKeys
I am trying to establish Group numbers that would link all the related ones
together...
Notice that Ord 1 , Inv 1 has 3 different FrtKey values (XYZ, ABC, and DEF)
Notice that Ord 3, Inv 4 has 1 different FrtKey value (XYZ)
- since XYZ appears on Ord 1, Inv 1 it needs to be grouped with it
Notice that Ord 4, Inv 7 has 1 different FrtKey value (ABC)
- since ABC appears on Ord 1, Inv 1 it needs to be grouped with it
The result set I would like to achieve in this case would be
Ord,Inv, FrtKey
('1','1','XYZ') Group = 1
('1','1','ABC') Group = 1
('1','1','DEF') Group = 1
('3','4','XYZ') Group = 1
('4','7','ABC') Group = 1
('2','3','ZZZ') Group=2
('3','5','ZZZ') Group=2
('4','8','ZAK') Group=3
Thanks !
"M A Srinivas" <masri999@gmail.com> wrote in message
news:1174921100.436392.43690@y66g2000hsf.googlegroups.com...
> On Mar 26, 6:59 pm, "Rob" <r...@yahoo.com> wrote:
>> CREATE TABLE [dbo].[tblManyToMany] (
>> [Ord] [char] (10) NULL ,
>> [Inv] [char] (10) NULL ,
>> [FrtKey] [char] (10) NULL
>> ) ON [PRIMARY]
>> GO
>>
>> INSERT INTO tblManyToMany Values('1','1','XYZ')
>> INSERT INTO tblManyToMany Values('1','1','ABC')
>> INSERT INTO tblManyToMany Values('1','1','DEF')
>> INSERT INTO tblManyToMany Values('3','4','XYZ')
>> INSERT INTO tblManyToMany Values('4','7','ABC')
>> INSERT INTO tblManyToMany Values('2','3','ZZZ')
>> INSERT INTO tblManyToMany Values('3','5','ZZZ')
>> INSERT INTO tblManyToMany Values('4','8','ZAK')
>>
>> Given the above, I am trying to match Freight bills with invoices.
>> There
>> is a many to many relationship.
>>
>> What I would like to do is create goups such that all like Ord + Inv are
>> grouped with any and all instances of FrtKey.
>>
>> AKA...
>>
>> ('1','1','XYZ')
>> ('1','1','ABC')
>> ('1','1','DEF')
>> ('3','4','XYZ')
>> ('4','7','ABC')
>>
>> The above would represent 1 group because they are all related. I want
>> to
>> keep all freight bills together, while at the same time, keep all Ord +
>> Inv
>> together.
>>
>> Any Ideas ?
>
> Your request is not clear . Can you elobarate with example what you
> want ?
>