title: How to fetch monthly attendance report from attendance table through mysql query?
body: <p>I need to show monthly attendance report for a particular student from MySQL table. I need result like below,</p>
  
  <p>I have attendance table in my database which is shown in the image below:</p>
  
  <p><a href="https://i.stack.imgur.com/S7jM0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S7jM0.jpg" alt="enter image description here"></a></p>
  
  <p>I want to fetch data from my attendance table where <strong>remarks '1' means 'present'</strong> like below:
  I need MySQL query to fetch the data like below</p>
  
  <p><strong>Please anyone help me to write query</strong></p>
  
  <p>My query is </p>
  
  <pre><code>SELECT YEAR(att_date) AS y, MONTH(att_date) AS m, COUNT(DISTINCT att_date) FROM attendance WHERE class_id=11 AND student_id=15 GROUP BY y, m
  </code></pre>
  
  <p>But didn't got the expected result as below</p>
  
  <p>For <strong>student-ID- 15</strong></p>
  
  <pre><code>CLASS   STUDENT_ID  YEAR    MONTH   TOTAL_CLASSES   TOTAL_PRESENT
  
  11      15      2016    April         21             20
  11      15      2016    May           25             25
  11      15      2016    June          30             29
  11      15      2016    July          18             18
  11      15      2017    January       28             28
  </code></pre>