1
Could you tell me what’s wrong with this SQL code? I want for each film, the wages of each staff do not appear repeated, that is, if in the first film has 2 leads, in the table I want the sum of these values for the lead.
select Ms.salary as Total_salaries, R.title as papeis, M.title as filmes
from Movies M, Staff St, MovieStaff Ms, Roles R
where Ms.mvid=M.mvid
and Ms.stid=St.stid
and Ms.rid=R.rid
union
select Ma.salary as Total_salaries, Ar.title as papeis_atores, M.title as filmes
from Movies M, Staff St, MovieActors Ma, ActorRoles Ar, Actors A
where Ma.mvid=M.mvid
and Ma.aid=A.aid
and A.aid=St.stid
and Ma.arid=Ar.arid;