Removing the duplicates and combining the data in one line.

Parent Group Nested Level 1 Nested Level 2 Nested Level 3
A A D G
A D E H
A D G I
A E G I
A E G I
B E H
B F H
C F H
C F
C
C
C

How do I combine these values in one line and remove duplicates using script? 

Parents
  • The nested levels may make this not applicable. Are you saying a parent group is a TABLE? And nested level1 is another TABLE. So you have 4 TABLES total?  A way to quickly remove duplicates is to union a TABLE with itself.

    Or use windows functions (though I cannot remember what Windows functions are....)

    Last, use ROW_NUMBER() to identify: duplicates:
    select country, region, city, ROW_NUMBER() OVER(Partition by country order by country) as multiple
    FROM Sales.Customers
    THEN……filter using CTE
    WITH CTE_DupID
    AS (
    select country, region, city,
    ROW_NUMBER() OVER(Partition by country,region,city order by country) as DD
    FROM Sales.Customers  –this “TAGS” all the duplicates
    )  — now identify and filter
    SELECT * from CTE_DupID
    where DD > 1 –where Dups = 1

    .........will get the unique distinct customers

Reply Children
No Data