<p>Trying to find some simple SQL Server PIVOT examples.  Most of the examples that I have found involve counting or summing up numbers.  I just want to pivot some string data.  For example, I have a query returning the following.</p>

<pre><code>Action1 VIEW  
Action1 EDIT  
Action2 VIEW  
Action3 VIEW  
Action3 EDIT  
</code></pre>

<p>I would like to use PIVOT (if even possible) to make the results like so:</p>

<pre><code>Action1 VIEW EDIT  
Action2 VIEW NULL  
Action3 VIEW EDIT  
</code></pre>

<p>Is this even possible with the PIVOT functionality?</p>

Well, for your sample and any with a limited number of unique columns, this should do it.
```
```
select 
    distinct a,
    (select distinct t2.b  from t t2  where t1.a=t2.a and t2.b='VIEW'),
    (select distinct t2.b from t t2  where t1.a=t2.a and t2.b='EDIT')
from t t1
```
```