Haadi Owais Haadi Owais - 3 months ago 21
SQL Question

List all the rows that satisfy a condition in mysql

i have done a attendance table with columns as follows:

where is present is of boolean datatype.
i want to retrieve all the rows whose attendance is less than 75%.
using avg() function it lists each students avg but how to retrieve the details of students whose avg() is less than a particular value.

I am new to sql and I seriously need help.

Thanks in advance.


You can use HAVING:

SELECT usn, name, AVG(ispresent) attendance FROM table 
GROUP BY usn, name HAVING attendance < 0.75;