1、List the films where the yr is 1962 and the budget is over 2000000 [Show id, title]
SELECT id, title
FROM movie
WHERE yr=1962 and budget>2000000
2、Give year of 'Citizen Kane'.
select yr from movie where title = 'citizen kane'
3、List all of the Star Trek movies, include the id, title and yr (all of these movies start with the words Star Trek in the title). Order results by year.
select id,title,yr
from movie
where title like 'star trek%'
order by yr
4、What id number does the actor 'Glenn Close' have?
select id from actor where name = 'glenn close'
5、What is the id of the 1942 film 'Casablanca'
select id from movie
where title = 'casablanca' and yr = 1942
6、Obtain the cast list for 1942's 'Casablanca'.
select name from actor join casting on actor.id=actorid
where movieid = (select id from movie where title = 'casablanca' and yr = 1942)
7、Obtain the cast list for the film 'Alien'
select name from actor join casting on actor.id=actorid
where movieid = (select id from movie where title = 'alien')
8、List the films in which 'Harrison Ford' has appeared
select title from movie
join casting on movie.id=movieid
join actor on actor.id=actorid
where name='harrison ford'
9、List the films where 'Harrison Ford' has appeared – but not in the starring role. [Note: the ord field of casting gives the position of the actor. If ord=1 then this actor is in the starring role]
select title from actor join casting on actor.id = actorid
join movie on movie.id = movieid
where name = 'harrison ford' and ord!=1
10、List the films together with the leading star for all 1962 films.
SELECT title, name from actor
join casting on actor.id = actorid
join movie on movie.id = movieid
where yr = 1962 and ord = 1
11、Which were the busiest years for 'Rock Hudson', show the year and the number of movies he made each year for any year in which he made more than 2 movies.
SELECT yr,COUNT(title) FROM
movie JOIN casting ON movie.id=movieid
JOIN actor ON actorid=actor.id
WHERE name='rock hudson'
GROUP BY yr
HAVING COUNT(title) > 2
12、List the film title and the leading actor for all of the films 'Julie Andrews' played in.
SELECT title, name FROM casting
join movie on movieid=movie.id
join actor on actor.id=actorid
WHERE movie.id IN (
SELECT movieid FROM actor join casting on actor.id=actorid
WHERE name='Julie Andrews')and ord=1
13、Obtain a list, in alphabetical order, of actors who've had at least 15 starring roles.
select distinct name from actor
join casting on actor.id=actorid
join movie on movieid=movie.id
where actorid in
(select actorid from casting where ord=1 group by actorid having count(movieid)>=15 )
14、List the films released in the year 1978 ordered by the number of actors in the cast, then by title.
select title, count(ord) from movie join casting on movieid = movie.id
where yr = 1978 group by title order by count(ord) desc, title
15、List all the people who have worked with 'Art Garfunkel'.
select distinct name from actor
join casting on actor.id = actorid
where movieid in
(select movieid from casting join actor on actorid = actor.id
join movie on movie.id = movieid
where name = 'art garfunkel') and name != 'art garfunkel'



