将连接查询转换为嵌套查询

时间:2016-11-13 16:03:22

标签: mysql sql database database-design time-and-attendance

如何将此查询转换为使用where where in条件的嵌套查询?

SELECT schedule.subcode,attendance.usn,avg(attendance.ispresent)* 100 as Attendance_Percentage 从计划JOIN出勤ON schedule.sched_id = attendance.sched_id 在哪里usn =“4jc14is013”AND subcode =“is530”;

1 个答案:

答案 0 :(得分:0)

您可以使用HAVING

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