title: Postgres - Convert columns to rows based on groupby
body: <p>I have a table </p>
  
  <p><a href="https://i.stack.imgur.com/bmHgE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bmHgE.png" alt="enter image description here"></a></p>
  
  <p>which I want to convert to below format</p>
  
  <p><a href="https://i.stack.imgur.com/tmIGM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tmIGM.png" alt="enter image description here"></a></p>
  
  <p>I tried with group by and tried with crosstab query but doesn't seem to work.</p>