I want to change my data from this:
| ID | Date |
|---|---|
| 2245873 | 03-JAN |
| 2245873 | 03-JAN |
| 2245873 | 04-JAN |
| 8394313 | 03-JAN |
| 8394313 | 04-JAN |
| 8394313 | 05-JAN |
| 3446512 | 31-DEC |
| 3446512 | 20-JAN |
| 617828 | 31-DEC |
| 617828 | 03-JAN |
| 617828 | 20-JAN |
| 61342 | 02-JAN |
to this:
| ID | date1 | date2 | date3 |
|---|---|---|---|
| 2245873 | 03-JAN | 04-JAN | |
| 8394313 | 03-JAN | 04-JAN | 05-JAN |
| 3446512 | 31-DEC | 20-JAN | |
| 617828 | 31-DEC | 03-JAN | 20-JAN |
| 61342 | 02-JAN |
- Remove the duplicate values for each ID (see ID=2245873),
- List the dates associated with each ID in a row,
I don't know how many dates each ID has so the number of columns I need is unknown, is this possible?
I also need to be able to merge this new table with another, so it needs to be a view or alter table?
If there are no more dates associated with an ID I want the cell to be null
Table name: dbo.rem