title: how to generate students mark ledger from 3 tables- Student,Mark,Subject
body: <p>I have four tables  <br/>
  1.student-it contains id name etc <br/>
  2.marks - it contains markid,student_id,batch,class,section,subject_id,exam_id,obt_mark <br/>
  3.subject table - it contains sub_id,sub_name<br/>
  4. exam_type- examtype_id, exam_name <br/>
  <br/>
  i need mark ledger for batch-2014,class=5,section=1,exam_id=3 as shown below- <br/></p>
  
  <pre>
      NAME   ROLL NO   SUB1   SUB2    SUB3  TOTAL  RESULT  POSITION RANK
      RAM     0054     65     54      64     183     PASS    FIRST    2
      HAri    0054     65     54      65     184     PASS    FIRST    1
      gopal   0054     65     50      65     180     PASS    FIRST    3
      saroj   0054     65     44      65     174     PASS    FIRST    4
  
  </pre>
  
  <p>Thanks in advance .</p>
  
  <p>Here i have sql query</p>
  
  <pre>                                  
  SELECT `marklists`.`mrk_sub_id1`, `marklists`.`mrk_marks`, `marklists`.`mrk_practical`,
  `marklists`.`mrk_exam_type`, `students`.`id` as st_id, `students`.`st_roll`, 
  `students`.`st_name`, `students`.`batch`, `students`.`st_class`, 
  `students`.`st_section`,   `courses`.`id`, `classes`.`class_name` as class_name,    
  `courses`.`sb_name` as subject_name, `courses`.`sb_fullmark` as full_marks,     
  `courses`.`sb_passmark` as pass_marks FROM (`marklists`)
   LEFT JOIN `classes` ON   `marklists`.`mrk_class` = `classes`.`id` 
  LEFT JOIN `students`  ON   `marklists`.`mrk_student_id`=`students`.`id` 
  LEFT JOIN `courses` ON   `marklists`.`mrk_sub_id`=`courses`.`id` 
  WHERE `marklists`.`mrk_exam_type` = '3' AND   `marklists`.`mrk_batch` = '3' 
  AND `marklists`.`mrk_class` = '1' AND   `marklists`.`mrk_section` = '1'
  </pre>
  
  <p>and I need ledger like above any help??</p>