Haadi Owais Haadi Owais - 1 year ago 77
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";

Answer Source

You can use HAVING:

SELECT usn, name, AVG(ispresent) attendance FROM table 
GROUP BY usn, name HAVING attendance < 0.75;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download