I have an issue that is like a non-aggregating pivot, but I want my table to include multiple results. As an example I start out like this:
ID | OrganizationID | Group | Vendor | Product
1 3 G1 V1 P1
2 3 G1 V2 P2
3 3 G2 V3 P3
4 4 G1 V1 P1
5 4 G1 V1 P2
And need my data to end up like this:
ID | OrganizationID | G1_V1 | G1_V2 | G2_V3
1 3 P1 P2 P3
2 4 P1 NULL NULL
3 4 P2 NULL NULL
The data I am working with is around 7 million rows so self-joining with dynamic sql has proven extremely slow. Is there something easy I'm missing? Thanks in advance!