title: How to achieve this model
body: <p>I have a table like this</p>
  
  <p><img src="https://i.stack.imgur.com/ng09T.png" alt="I have a table like this"></p>
  
  <p>I am trying to achieve a table like this:
  <img src="https://i.stack.imgur.com/gKwmV.png" alt="enter image description here"></p>
  
  <p>this was my query.</p>
  
  <pre><code>select name,token , sum(qty) [Qty],sum(amount)from #temp 
   group by token,name
  </code></pre>
  
  <p>tried like this..</p>
  
  <pre><code> SELECT *
   FROM   (SELECT  name,
                 qty,amt,
                 Token
                 FROM   #temp1
         ) AS D
         PIVOT(Sum(amt)
              FOR Token IN ([10],[20],[100],[40],[5])) AS P 
  </code></pre>
  
  <p>it is not working though.
  Any help will be appreciated.</p>