Hi Experts,
I need to do is remove all the words that are not contained in every record of the each groupingid group .
That is I need is a way to strip out any text from a group that is not contained in all rows of the group with a space as deliminator
CREATE TABLE #TEMP
(
GROUPINGID INT ,
DESCRIPTION VARCHAR(MAX)
)
INSERT INTO #TEMP
SELECT 2,'Hat red' UNION ALL
SELECT 2,'Hat green' UNION ALL
SELECT 2,'Hat yellow' UNION ALL
SELECT 3,'Yellow Mens Sweater' UNION ALL
SELECT 3,'Green Mens Sweater' UNION ALL
SELECT 4,'ENDURO STYLE GRIPS BLUE' UNION ALL
SELECT 4,'ENDURO STYLE GRIPS RED' UNION ALL
SELECT 4,'OURY STD GRIP/BLACK/LOW FLANGE' UNION ALL
SELECT 5,'PLEXUS 1/2 OUNCE' UNION ALL
SELECT 5,'PLEXUS 7 OUNCE' UNION ALL
SELECT 5,'PLEXUS 13 OUNCE'
GROUPINGID DESCRIPTION
2 Hat red
2 Hat green
2 Hat yellow
3 Yellow Mens Sweater
3 Green Mens Sweater
4 ENDURO STYLE GRIPS BLUE
4 ENDURO STYLE GRIPS RED
4 OURY STD GRIP/BLACK/LOW FLANGE
5 PLEXUS 1/2 OUNCE
5 PLEXUS 7 OUNCE
5 PLEXUS 13 OUNCE
Expected output:
groupid description
2 Hat
3 Mens Sweater
4 NULL (this is null because the same word is not repeated in all rows)
5 PLEXUS OUNCE
Please help me.
Thanks!