I tried searching and found a lot of solutions for problems with "identical" id, but my problem is dealing with "similar" ids.
I have a table with a bunch of tasks, task description, and procedure notes. Each task may have multiple sub-tasks. I need to combine all subtask information into one cell. The table looks like below:
| TaskID | Description | Procedure Notes |
|---|---|---|
| Task-1 | General Description | null |
| Task-1-1 | Step 1 Task | Step 1 Notes |
| Task-1-2 | Step 2 Task | Step 2 Notes |
| Task-1-3 | Step 3 Task | Step 3 Notes |
| C-Task-2 | General Description | null |
| C-Task-2-01 | Step 1 Task | Step 1 Notes |
| C-Task-2-02 | Step 2 Task | Step 2 Notes |
Desired Result (formatting keeps breaking sorry):
| TaskID | Description |
| Task-1 | Step 1 + Step 1 Notes, Step 2 + Step 2 Notes, Step 3 + Step 3 Notes |
Since the naming of TaskID is not consistent I can't just trim and compare. I have tried using XML PATH / STUFF, but that only lets me do one task at a time and I have hundreds. I also don't have access to STRING_AGG.
Any help is appreciated. Thanks!
TaskIDis inconsistent, and if it's varied to the point where you can't use any sort of business logic to extract meaningful identifiers from your column, I would say it's nearly impossible with any level of accuracy/certainty.