title: optimizing sql query which involves 3 tables and joins
body: <p>i am having state schools result data. i normalized database and created three tables i.e. marks table, schools table and student table. i want to write the query to get pass of each schools. here i pasted query for getting total students appeared for exams and in the same way i ll get passed students. </p>
  
  <pre><code>     SELECT a.Year_id
       , school_code
       , count(a.Marks_id) AS TotalAppeared
  FROM
    Marks_Table a
    JOIN Master_Student ms
      ON ms.Student_id = a.Student_id
    JOIN Master_School mss
      ON mss.school_id = ms.School_code_int
  WHERE
    CANDIDATE_TYPE = 'RF'
    AND TOTAL_MARKS != 0
    AND school_code = 'AS0180'
    AND a.Year_id BETWEEN 5 AND 9
  GROUP BY
    a.Year_id
  , SCHOOL_CODE             
  </code></pre>
  
  <p>how to optimize this query </p>