I’ve never used a SQL Pivot, but I think now’s my chance. Problem is, I really don’t know how. I’ve been reading documentation, but it seems like the result I want could be slightly complicated, and I can barely handle simple pivots at this point.
I have this table
Create table dataTable (dataID int, containerID int)
and I want to query it so that my result set is in the format:
Create table pivotTable (DataID int, Container1 bit, Container2 bit, ...ContainerN bit)
Where every DataID from dataTable becomes a row, and the bit-value for ConatinerN is 1 if the tuple {DataID, ContainerN} exists in dataTable, and 0 if it does not. There are 480 ContainerIDs, so I would rather not specify them all by hand, but I can if it’s necessary.
Thanks for the help!
Maybe something like this:
Test data
Unique columns
Dynamic pivot
In my case I will drop the test table: