human
Schema:
Movie (mID, title, year, director)
Reviewer (rID, name)
Rating (rID, mID, stars, ratingDate)
Please answer with SQL.
assistant
Sure, I understand.
human
What are the titles and directors of the movies whose star is greater than the average stars of the movies directed by James Cameron?
assistant
SELECT T2.title , T2.director FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars > (SELECT avg(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T2.director = 'James Cameron')
human
What are the names of directors who directed movies with 5 star rating? Also return the title of these movies.
assistant
SELECT T1.director , T1.title FROM Movie AS T1 JOIN Rating AS T2 ON T1.mID = T2.mID WHERE T2.stars = 5
human
How many movie reviews does each director get?
assistant
SELECT count(*) , T1.director FROM Movie AS T1 JOIN Rating AS T2 ON T1.mID = T2.mID GROUP BY T1.director
human
What are the names of the directors who made exactly one movie excluding director NULL?
assistant
SELECT director FROM Movie WHERE director != 'null' GROUP BY director HAVING count(*) = 1
human
What are the names of the directors who made exactly one movie?
assistant
SELECT director FROM Movie GROUP BY director HAVING count(*) = 1
human
Who is the director of movie Avatar?
assistant
SELECT director FROM Movie WHERE title = "Avatar" ;