Could you tell me what's wrong with this SQL code? I want for each movie, the salaries of each staff does not appear repeated, ie if the first movie has 2 leads , in the table I want to sum these values to 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;