'SQL distinct if previously occuring
I want to collapse rows if a column has already appeared...
SQL Server - table structure:
CREATE TABLE Docs
(
Area varchar(max),
RootFolder varchar(max),
SubFolder varchar(max),
)
Raw data:
| Area | RootFolder | SubFolder |
|---|---|---|
| One | 12345 | |
| One | 12345 | 6789 |
| One | 12345 | AAAAA |
| One | CCCCC | |
| One | DDDDDD | |
| One | DDDDDD | FFFFFF |
| One | DDDDDD | GGGGG |
I want:
| Area | RootFolder | SubFolder |
|---|---|---|
| One | 12345 | 6789 |
| One | 12345 | AAAAA |
| One | CCCCC | |
| One | DDDDDD | FFFFFF |
| One | DDDDDD | GGGGG |
I've tried group bys and other window functions but I don't know how to get the output I want
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
