Write the SQL queries (select statements) to obtain the following information 1-
ID: 3819857 • Letter: W
Question
Write the SQL queries (select statements) to obtain the following information
1- List of all movies
2-List of all Action movies
3-List of all Comedy movies
4- List of all movies released after Jan 1, 2001
5- List of all directors
6- List of all movies directed and written by the same person
7- Number of Action movies
8- Number of movies released before Jan 1, 2001
9- List of all writers who have written comedy movies released before Jan 1, 2005
10- List of all directors who have directed action movies released after Jan 1, 2005
Explanation / Answer
Movies
MovID
MovieName
Genre
WritID
DirID
ReleaseDate
Directors
DirID
DirectorName
Writers
WritID
WriterName
Write the SQL queries (select statements) to obtain the following information
SELECT MovieName from Movies
SELECT MovieName from Movies where Genre = ‘Action’
SELECT MovieName from Movies where Genre = ‘Comedy’
SELECT MovieName from Movies where ReleaseDate > 20010101
//using the format YYYYMMDD for date
SELECT DirectorName from Directors
SELECT MovieName from Movies where WritID = DirID
SELECT COUNT(MovieName ) FROM Movies where Genre = ‘Action’
SELECT COUNT (MovieName) from Movies where ReleaseDate < 20010101
//using the format YYYYMMDD for date
SELECT Writers.WriterName, Movies.MovieName
FROM Writers
INNER JOIN Movies ON Writers. WritID =Movies.WritID and Movies .ReleaseDate < 20050101 and Movies.Genre = ‘Comedy’
SELECT Directors.DirName, Movies.MovieName
FROM Directors
INNER JOIN Movies ON Directors.DirID =Movies.DirID and Movies .ReleaseDate > 20050101 and Movies.Genre = ‘Action’
MovID
MovieName
Genre
WritID
DirID
ReleaseDate
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.