Hi! I'm new to SQL I'm having trouble correctly using the avg and sum function. I'm working with the database above. I need to find the average profit for each movie star but only output that average only if the sum of their profits is > 200.
SELECT MovieStar.sname, avg(profit) From MovieStar, Movie
GROUP BY sname
HAVING sum(Movie.profit) > 200
I'm using SQL Fiddle to try and figure this out, but it seems to be returning the avg of the WHOLE profit column and not each actor but I'm not sure what I could be doing wrong. How can I approach this so I can get the avg of each actor and not the avg of the whole profit column? Here is the SQL Fiddle I made. Thanks in advance!