title: A better way for transformation
body: <p>I have something as</p>
  
  <p><a href="https://i.stack.imgur.com/Gc7ra.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gc7ra.jpg" alt="enter image description here"></a> </p>
  
  <p>obtained by running the script </p>
  
  <pre><code>declare @t table(id int identity, bucket varchar(200), startinventory int, nocontact int)
  
  INSERT INTO @t  
  SELECT 'bucket1',1234,72500 UNION ALL  
  SELECT 'bucket2',6784,60500 UNION ALL  
  SELECT 'bucket3',678,52000 UNION ALL  
  SELECT 'bucket4',234,45000 
  
  select * from @t 
  </code></pre>
  
  <p>Looking for a transformation whose output will be</p>
  
  <p><a href="https://i.stack.imgur.com/jyCbR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jyCbR.jpg" alt="enter image description here"></a></p>
  
  <p>The present script which does the transformation is presented below</p>
  
  <pre><code>select 'startinventory'  as Activities,
      bucket1=(select startinventory from @t where id=1),
      bucket2=(select startinventory from @t where id=2), 
      bucket3=(select startinventory from @t where id=3),
      bucket4=(select startinventory from @t where id=4) union all
  select 'nocontact', 
      (select nocontact from @t where id=1),
      (select nocontact from @t where id=2), 
      (select nocontact from @t where id=3),
      (select nocontact from @t where id=4)
  </code></pre>
  
  <p>Is there a better way to write the script?</p>