任何人都可以帮助我,我有相关的嵌套子查询的问题,即,当我试图在嵌套的子查询中使用祖父列时,我得到了这个错误
错误代码:1054'where子句'中的未知列'scu.iUserId'
查询:
SELECT scu.iUserId, (SELECT SUM( sbs.`iNoPointsBeginning` + (SELECT COALESCE(SUM(BehaviorPts), 0) AS StudentPts FROM (SELECT ( COUNT(sbis.iIncidentSubmissionId) * sbi.iPointValue ) AS BehaviorPts FROM scn_behavior_incident_submission sbis JOIN scn_behavior_incident_actors sbia ON sbia.iIncidentSubmissionId = sbis.iIncidentSubmissionId LEFT JOIN scn_behavior_incidents sbi ON sbi.iIncidentId = sbis.iBehaviorIncidentId WHERE sbia.iUserId = scu.iUserId AND sbia.eActorType 'Witness' AND sbis.iSchoolId = '97' GROUP BY sbis.iBehaviorIncidentId) AS BehaviorTotal) ) AS stu_pt FROM scn_behavior_settings sbs WHERE sbs.`iSchoolId` = '97') FROM scn_sections_members AS scm INNER JOIN scn_users AS scu ON scu.iUserId = scm.iStudentId