Resoving: The multi-part identifier could not be bound.

When I try to perform a JOIN on a query with multiple tables listed in the from clause I often get the error "The multi-part identifier could not be bound." Is there a specific reason for this?

thoughts?
select RSEC_ACTIVITY_SCHEDULE_DETAIL.trainee_id,
RSEC_ATTENDANCE.course_status_cd, count (traineeAbsent.attendance_id) as times_absent,
count(RSEC_ATTENDANCE.attendance_id) as total_ACTIVITYes
 
from dbo.RSEC_ACTIVITY_SCHEDULE_DETAIL,dbo.RSEC_ATTENDANCE
 
left join RSEC_ATTENDANCE traineeAbsent ON traineeAbsent.attendance_id = dbo.RSEC_ATTENDANCE.attendance_id 
    AND (traineeAbsent.status_cd='AttendanceStatus_ACTIVITYMissed' or 
         traineeAbsent.status_cd='AttendanceStatus_SickDay')
         
left join RSEC_TRAINEE  ON RSEC_TRAINEE.trainee_id = RSEC_ACTIVITY_SCHEDULE_DETAIL.trainee_id
 
 
where RSEC_ACTIVITY_SCHEDULE_DETAIL.ACTIVITY_schedule_id=33
and RSEC_ACTIVITY_SCHEDULE_DETAIL.ACTIVITY_schedule_detail_id  = RSEC_ATTENDANCE.ACTIVITY_schedule_detail_id
 
group by RSEC_ACTIVITY_SCHEDULE_DETAIL.trainee_id,RSEC_ATTENDANCE.course_status_cd

Open in new window

bryan_zAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
yes, the reason is that you try to use a table.column in your query, although the table is not in the from/join anywhere.
in your query, I see that you mix join and non-join yntax, which is not good.
finally, I suggest you use table aliases in your query... make things easier to read#:
select sd.trainee_id
, a.course_status_cd
, count(ta.attendance_id) as times_absent
, count(a.attendance_id) as total_ACTIVITYes 
from dbo.RSEC_ACTIVITY_SCHEDULE_DETAIL sd
join dbo.RSEC_ATTENDANCE a
  on sd.ACTIVITY_schedule_detail_id  = a.ACTIVITY_schedule_detail_id
left join RSEC_ATTENDANCE ta  
  ON ta.attendance_id = a.attendance_id 
 AND ta.status_cd IN ( 'AttendanceStatus_ACTIVITYMissed', 'AttendanceStatus_SickDay')
left join RSEC_TRAINEE  t
  ON t.trainee_id = sd.trainee_id
where sd.ACTIVITY_schedule_id=33
group by sd.trainee_id
    , a.course_status_cd

Open in new window

0
 
newbiealCommented:
Here is some info that might explain the issue and provides a good solution:
http://aartemiou.blogspot.com/2009/01/multi-part-identifier-could-not-be.html

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.