With SQL Server, I would like to pivot or group multiple date columns per id like in the example below:
Four columns from table [db].[exampletable]
, Id
, 1/1
, 2/1
, 3/1
Id | 1/1 | 2/1 | 3/1 |
---|---|---|---|
117 | 10 | 5 | 20 |
118 | 5 | 10 | 15 |
119 | 20 | 15 | 15 |
120 | 20 | 20 | 15 |
Desired Result:
Id | date | sum |
---|---|---|
117 | 1/1 | 10 |
117 | 2/1 | 5 |
117 | 3/1 | 20 |
118 | 1/1 | 5 |
118 | 2/1 | 10 |
118 | 3/1 | 15 |