I need to set a value to 1 in table where the count for a given role in another table is > 1.
The table cursillo.members has fields memid and hsd. Table cursillo.teams has fields memid (the link between the two) a field called movement and another called role.
What I am trying to accomplish is something similar to this:
update cursillo.members_eligible p, cursillo.teams pp
   set p.hsd=1     
 where p.memid = pp.memid AND (pp.role = 'HSD' OR pp.role = 'SD')
   and pp.movement = 'Cursillo' AND count(pp.role) > 1;
or this:
update members_eligibile
   set hsd=1 
  from teams 
 where teams.memid=members_eligible.memid 
   and (teams.role = 'HSD' OR teams.role = 'SD')  
   and teams.movement = 'Cursillo' 
   and count(teams.role) > 1;
In other words if a given memid has more than one record in the cursillo.teams table where the value of the role is equal to either HSD or SD, then set cursillo.members_eligible.hsd to 1.
I can't figure out to handle the count() part.
Thanks, Mike Reed
 
     
     
     
    