I'm trying to pivot a SQL Server table whilst also grouping by the date column.
This is my example data:
| date | ref | count |
|---|---|---|
| 07/06/21 | ref1 | 20 |
| 08/06/21 | ref1 | 2 |
| 09/06/21 | ref1 | 15 |
| 07/06/21 | ref2 | 54 |
| 08/06/21 | ref2 | 23 |
And how the result needs to be:
| ref | 07/06/21 | 08/06/21 | 09/06/21 |
|---|---|---|---|
| ref1 | 20 | 2 | 15 |
| ref2 | 54 | 23 |
Is it possible to do this with a SQL Server PIVOT, or does it require something else to do the grouping?
The dates are dynamic as well and based on a date range.