title: MySQL Every derived table must have its own alias
body: <p>Hi I need to generate an sql query by joining two queries</p>
  <p>1st Query : Getting all students data</p>
  <pre><code>SELECT * FROM students where class = 1 and section = 'A'
  </code></pre>
  <p><img src="https://i.stack.imgur.com/G77VR.png" alt="enter image description here" /></p>
  <p>2nd Query : Getting the count of each attendance</p>
  <pre><code>SELECT  roll_no,full_name, 
  
  SUM(hasAttended= 'P') AS DaysPresent, 
  
  SUM(hasAttended= 'A') AS DaysAbsent, 
  
  COUNT(*) AS totalClasses
  
  FROM     attendance
  
  GROUP BY roll_no
  </code></pre>
  <p><img src="https://i.stack.imgur.com/4w6v5.png" alt="enter image description here" /></p>
  <p>NOW I need to join the two tables and produce a resultant table</p>
  <p>I am trying the following query but getting an error :</p>
  <blockquote>
  <h1>1248 - Every derived table must have its own alias</h1>
  </blockquote>
  <p>My Query is as follows :</p>
  <pre><code>SELECT * FROM students as st
  
  INNER JOIN 
  
  (SELECT  att.roll_no,att.full_name, 
  
  SUM(att.hasAttended= 'P') AS DaysPresent, 
  
  SUM(att.hasAttended= 'A') AS DaysAbsent, 
  
  COUNT(*) AS totalClasses
  
  FROM     attendance as att
  
  GROUP BY att.roll_no)
  
  ON st.roll_no = att.roll_no
  
  ORDER BY  st.roll_no
  </code></pre>
  <p>Can anybody please solve the above error</p>