Haadi Owais Haadi Owais - 5 months ago 41
MySQL Question

convert join query into nested query

how to convert this query into a nested query which uses where in condition?

SELECT schedule.subcode,attendance.usn,avg(attendance.ispresent)*100 as Attendance_Percentage
FROM schedule JOIN attendance ON schedule.sched_id=attendance.sched_id
WHERE usn="4jc14is013" AND subcode="is530";


You can use HAVING:

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