I am having trouble with this query. I have read quite a few things but have yet to find a solution. The problem is with the subquery- it really doesn’t like it. Can someone help me get this to work?
The first table represents a Work Performed table and the second talbe shows Employee Information. I am basically trying to get a supervisor name for an employee using the ‘position_reports_to’ field which is an HR code. By the way, this is in Teradata.
Thanks!
select
t1.record_number,
T1.record_created_by,
T2.last_name,
T2.first_name,
T2.employee_no,
t2.position_number,
T2.position_reports_to as SUPID,
(select last_name from T2 where SID=T2.position_nbr) as SUP
from T1
left join T2 on T1.record_created_by=T2.employee_no
where
t1.record_create_date=current_date
You can try another
LEFT JOINinstead of the subquery: