title: Postgresql Split single row to multiple rows
body: <p>I'm new to postgresql. I'm getting below results from a query and now I need to split single row to obtain multiple rows. 
  I have gone through below links, but still couldn't manage it. Please help.
  <a href="https://stackoverflow.com/questions/1128737/unpivot-and-postgresql">unpivot and PostgreSQL</a>
  <a href="https://stackoverflow.com/questions/33919329/how-to-split-a-row-into-multiple-rows-with-a-single-query">How to split a row into multiple rows with a single query?</a></p>
  
  <p><strong>Current result</strong></p>
  
  <pre><code>id,name,sub1code,sub1level,sub1hrs,sub2code,sub2level,sub2hrs,sub3code,sub3level,sub3hrs --continue till sub15
  
  1,Silva,CHIN,L1,12,MATH,L2,20,AGRW,L2,35
  
  2,Perera,MATH,L3,30,ENGL,L1,10,CHIN,L2,50
  </code></pre>
  
  <p><strong>What we want</strong></p>
  
  <pre><code>id,name,subcode,sublevel,subhrs
  
  1,Silva,CHIN,L1,12
  
  1,Silva,MATH,L2,20
  
  1,Silva,AGRW,L2,35
  
  2,Perera,MATH,L3,30
  
  2,Perera,ENGL,L1,10
  
  2,Perera,CHIN,L2,50
  </code></pre>