Advanced SQL queries
Advanced SQL queries
The relational schema:
MOVIE(TITLE,DIRECTOR,YEAR)
CAST(TITLE,ACTOR)
Queries:
- List all the
actors that only played in `"Star Wars" and "The Return of Jedi."
- List all the actors and for each actor give the maximum number of
movies he/she made in a single year.
- 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).
- Find the actors that were never unemployed for more than 3 years.
- Find all the actors that made more movies with Spielberg than with any other director.
The relational schema:
EMP(NAME,DEPT,SALARY)
Queries:
- Find the employees who make more than twice the average salary in their
department.
- Find the departments whose salary total is more than twice
the average departmental salary total.
- Find the employees whose salaries are among the top 100 salaries.