Question

update dkc_hsp_pi a
set a.UaID = (select uid from 
(
select uid,
emplid,
max(EFFDT) 
from sysadm.ps_ua_eds_data
group by uid,
emplid ) s)
where s.emplid = a.emplid;
Was it helpful?

Solution

The alias "s" is unreachable from the place where you use it: try moving the WHERE clause up a level like this:

update dkc_hsp_pi a
set a.UaID = 
(
select uid from 
  (
    select uid,
           emplid,
           max(EFFDT) 
    from sysadm.ps_ua_eds_data
    group by uid, emplid 
  ) s
  where s.emplid = a.emplid
)
;

you'll need to change the first "=" to an "IN" if your subquery returns more than one result, or adjust the subquery accordingly (by returning a single row by filtering on row_number).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top