title: Select Multiple rows into one row in Oracle
body: <p>I have a table that stores student results for different exams and different exam types say main exam, continuous assessment, course work etc, I need to query the table such that I get only one row for one particular exam unit with the percentage averaged depending on the number of exams the students sat for. Here is my attempted query:</p>
  
  <pre><code>select stu_reg_no, unit_code, 
         exam_unit, exam_semester, 
         student_year,  
         sum(per_centage_score)/count(per_centage_score) percentage
   from student_results_master
  group by unit_code, exam_unit, 
           per_centage_score, stu_reg_no,  
           exam_semester, student_year;
  </code></pre>
  
  <p>Here is my resultset:</p>
  
  <p><img src="https://i.stack.imgur.com/VsrAR.jpg" alt="enter image description here"></p>
  
  <p>I have two rows for the same exam unit since one is main exam and the other course work I need my output like this:</p>
  
  <pre><code>E35/1000/2013   TFT001  COMPLEX ANALYSIS   1  1  71.04
  E35/1000/2013   TFT002  LINEAR ALGEBRA     1  1  56.25
  </code></pre>
  
  <p>The percentage for that particular unit is added and divided by the number of exams for that particular unit.
  How can I achieve this?</p>