Query to Find Parts with similar materials (1 Viewer)

vanhuiszoo

New member
Local time
Today, 09:14
Joined
Jul 27, 2017
Messages
3
Hello,

I need to come up with a query to find our products with similar materials, and i'm hitting a wall. Here is an example what my initial table looks like:

Code:
ID	PartNo	Material
1	sku1	A
2	sku1	B
3	sku1	C
4	sku2	A
5	sku2	C
6	sku3	B
7	sku3	C
8	sku4	A
9	sku4	B
10	sku4	C

What i need to find is how many parts are similar to each other. So i need to know that sku1 and sku4 both have the same materials, but also that sku1 and sku2 share 2 materials, etc. So my results should look something like:

Code:
PartNo	SameAs		CountOfMaterialsShared	MaterialsShared
sku1	sku4		3			A,B,C
sku1	sku2		2			A,C
sku1	sku3		2			B,C
sku2	sku1		2			B,C
sku2	sku3		1			C

What i can think of is that i need to loop over each sku and find all similar skus, but i can't think of how to do this in a query, but all of my data are in tables. so i'm stuck. Anyone have any ideas? Thank you!!
 

vanhuiszoo

New member
Local time
Today, 09:14
Joined
Jul 27, 2017
Messages
3
That looks promising - so are you saying to concatenate the values and then do the compare? That would get me the exact matches, but not those with partial matches - also would need to make sure the materials are ordered the same each time...
 

Minty

AWF VIP
Local time
Today, 17:14
Joined
Jul 26, 2013
Messages
10,371
You probably need to make a couple of queries, one to join the table to a copy of itself by materials then feed that into the concatenate function.
 

vanhuiszoo

New member
Local time
Today, 09:14
Joined
Jul 27, 2017
Messages
3
I'm sorry - i'm still confused - what am i outputting from the first query where i'm joining the table to itself by materials?
 

Users who are viewing this thread

Top Bottom