title: How to create dynamic pivot query in SQL
body: <p>I am trying to create dynamic pivot query in SQL but my issue is that the contract id and the tier desc columns are both dynamic and I could not figure out how to solve this issue. I have something like this:</p>
  
  <p><a href="https://i.stack.imgur.com/yDrkY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yDrkY.png" alt="enter image description here"></a></p>
  
  <p>and this is the output I would like to see</p>
  
  <p><a href="https://i.stack.imgur.com/uvKfl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uvKfl.png" alt="enter image description here"></a></p>