Advanced SQL queries

Advanced SQL queries

The relational schema:

MOVIE(TITLE,DIRECTOR,YEAR)
CAST(TITLE,ACTOR)

Queries:

  1. List all the actors that only played in `"Star Wars" and "The Return of Jedi."
  2. List all the actors and for each actor give the maximum number of movies he/she made in a single year.
  3. Find the actors with the longest career span (the difference between the year of the latest and the year of the earliest movie of the actor).
  4. Find the actors that were never unemployed for more than 3 years.
  5. Find all the actors that made more movies with Spielberg than with any other director.

The relational schema:

EMP(NAME,DEPT,SALARY)

Queries:

  1. Find the employees who make more than twice the average salary in their department.
  2. Find the departments whose salary total is more than twice the average departmental salary total.
  3. Find the employees whose salaries are among the top 100 salaries.