Hi,
I've the following table and the data in it as well as per below. My question now is, I've to find all orders that have similar products placed in the sales table.
So looking at the data entered, I should get output as - SO1,SO2,SO3,SO8,SO4,SO6 since
S01,SO2 have same products placed
SO3,S08 have same products placed
SO4,SO6 have same products placed
CREATE TABLE [dbo].[SALES_TEST](
[SALESID] [nchar](10) NULL,
[ITEMID] [nchar](10) NULL
) ON [PRIMARY]
INSERT INTO [dbo].[SALES_TEST]
([SALESID]
,[ITEMID])
VALUES
('SO1','BA1'),
('SO1','KM100'),
('SO1','SM1RR'),
('SO1','ZT6'),
('SO2','BA1'),
('SO2','KM100'),
('SO2','sM1RR'),
('SO2','ZT6'),
('SO3','BA1'),
('SO3','KM100'),
('SO3','SM1RR'),
('SO4','BA2'),
('SO4','KM200') ,
('SO4','SM1RR'),
('SO4','ZT6'),
('SO5','KM100'),
('SO5','SM1RR'),
('SO5','ZT6'),
('SO6','BA2'),
('SO6','KM200'),
('SO6','SM1RR'),
('SO6','ZT6'),
'SO7','BA2'),
('SO7','KM100'),
('SO7','SM1RR'),
('SO7','ZT6'),
('SO8','BA1'),
('SO8','KM100'),
('SO8','SM1RR')