update from joined table?

The below code returns the following rs:

select C.uniquekey,c.TotalNumAttempts, S.uniqueid, s.tel,s.callcount
from campaign c
      inner join results_end s on C.uniquekey=S.uniqueid
where c.uniquekey=620607


C.uniquekey     TotalNumAttempts        uniqueid    s.tel                 callcount
620607            NULL                           620607      01153454017    8


How would I copy the callcount to totalnumattemps?



LVL 3
XanderPAsked:
Who is Participating?
 
Atlanta_MikeConnect With a Mentor Commented:
update campaign
    set TotalNumAttempts = s.callcount
from campaign c
     inner join results_end s
      on C.uniquekey=S.uniqueid
where c.uniquekey=620607
0
 
rafranciscoConnect With a Mentor Commented:
Try this:

UPDATE C
SET TotalNumAttempts = S.CallCount
FROM campaign c inner join results_end s on C.uniquekey=S.uniqueid
where c.uniquekey=620607
0
 
devsolnsConnect With a Mentor Commented:
insert into totalnumattemps (column name you want to insert it into here)
select s.callcount
from campaign c
     inner join results_end s on C.uniquekey=S.uniqueid
where c.uniquekey=620607
0
 
LowfatspreadConnect With a Mentor Commented:
what do you mean by copy?

for display?
select C.uniquekey,coalesce(c.TotalNumAttempts,s.callout) as Attempts, S.uniqueid, s.tel,s.callcount
  from campaign c
  inner join results_end s
     on C.uniquekey=S.uniqueid
where c.uniquekey=620607

0
 
Atlanta_MikeCommented:
I assume you want to update the TotalNumAttempts in campaign from results_end.callcount?
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.