0

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";

  • 1
    `HAVING AVG(ispresent) < 0.75` – Paul Spiegel Nov 13 '16 at 16:06
  • 1
    Your database format is not in normal form. It should be two tables: `Persons(usn, name)` and `Presence(date, usn)`. See https://www.tutorialspoint.com/dbms/database_normalization.htm – lovasoa Nov 13 '16 at 16:22

1 Answers1

0

You can use HAVING:

SELECT usn, name, AVG(ispresent) attendance FROM table 
GROUP BY usn, name HAVING attendance < 0.75;
gr1zzly be4r
  • 2,072
  • 1
  • 18
  • 33