Skip to content
Advertisement

Dynamic Pivot of Email Addresses

I have tried to research this, and I am unable to find something quite like it. I have a table that may have entries added many times over as well as deleted. I have no idea how many columns I will need, therefore I need a Dynamic Pivot. All the examples I see use a windows function, but I am pivoting email addresses.

The Table would look something like this:

I want the table to look like this(when all are included):

If Number 1 wasn’t included it would look like:

Thanks for the help!

Here is code to create a mock table:

This is similar to what I have tried, I used count to try and just make it work, but was unable.

Advertisement

Answer

You first need to create a RNO by partition over Number. The following query should do what you want:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement