title: Merge two or more columns dynamically based on table columns?
body: <p>I have a table which is called <code>SectionNames</code> as follows</p>
  
  <pre>SectionID   SectionCode     Subsection
     1            xYz         Individual
     2            xYz         Family
     3            CYD         Friends
     4            PCPO        level1
     5            PCPO        level2
     6            PCPO        level3</pre>
  
  <p>So on. So in future we can add one or more subsections for each section code.</p>
  
  <p>And have one more table which is a reference table for above <code>SectionNames</code> table and <code>Employee</code> table with employee data.</p>
  
  <pre>ID    EmployeeID    SectionID   Cost    
  1           1              1    $200
  2           1              2    $300    
  3           1              3    $40 
  4           1              4    $10 
  5           1              5    No Level
  6           1              6    No Level
  7           1              7    $20 
  8           1              8    No Level
  9           1              9    No Level</pre>
  
  <p>So Iwant the out put from these tables should look like:</p>
  
  <pre><code>EmployeeID     Individual_xyz_Cost    Family_xyz_Cost    Friends_xyz_cost  level1_PCPO_cost  level2_PCPO_Cost
     1                 $200                 $300               $400              $10             NoLevel
  </code></pre>
  
  <p>There are few employee records exists in my employee table. And I want this to be dynamic. Like If in future if one more subsection called <code>Relatives</code> added for <code>XYZ</code> section then my query should return <code>Relatives_XYZ_Cost</code>.</p>
  
  <p>How can I write this query dynamically?</p>