-- number of actors in the database

SELECT COUNT(*) AS n_actors
FROM nza.Actor;


-- titles and years of release of all films, in reverse order by year

SELECT Title, Year
FROM nza.Movie
ORDER BY YEAR DESC;

-- titles of movies and names of actors who took part in the movie, 
-- so that all tuples for the same movie are listed together

SELECT Title, Name
FROM nza.Actor NATURAL JOIN nza.Part NATURAL JOIN nza.Movie
GROUP BY Title, Name;

-- titles of movies and number of actors who took part in it

SELECT Title, COUNT(*) AS n_actors
FROM nza.Actor NATURAL JOIN nza.Part NATURAL JOIN nza.Movie
GROUP BY Title;


-- order titles by the number of actors who acted in them, highest first

SELECT Title
FROM (SELECT Title, COUNT(*) AS n_actors
   FROM nza.Actor NATURAL JOIN nza.Part NATURAL JOIN nza.Movie
   GROUP BY Title)
ORDER BY n_actors DESC;




