How do I combine these values in one line and remove duplicates using script?
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 multipleFROM Sales.CustomersTHEN……filter using CTEWITH CTE_DupIDAS (select country, region, city,ROW_NUMBER() OVER(Partition by country,region,city order by country) as DDFROM Sales.Customers –this “TAGS” all the duplicates) — now identify and filterSELECT * from CTE_DupIDwhere DD > 1 –where Dups = 1.........will get the unique distinct customers
sorry, my mistake. I thought this was the SQL section of the forum. You are working with Powershell.
Powered by IDERA