1.Find all movies where the special features are not listed (i.e., special_features is NULL).
SELECT title FROM film WHERE special features = NULL;
Meaning : It returns the title of the movie where the special feature is null
2.Find all movies where the rental duration is more than 7 days.
SELECT title , rental FROM film WHERE rental_duration > 7;
Meaning : It returns the title of the movie and rental_duration more than 7 days
3.Find all movies that have a rental rate of $4.99 and a replacement cost of more than $20
SELECT title , rental_rate , replacement_cost FROM film WHERE rental_rate = 4.99 AND replacement_cost > 20;
Meaning : It returns the title of the movie , rental_rate is equal to 4.99 and replacement_cost more than 20
4.Find all movies that have a rental rate of $0.99 or a rating of 'PG-13'.
SELECT title , rental_rate , rating FROM film WHERE rental_rate = 0.99 OR rating = 'PG-13';
Meaning : It returns title , rental_rate with 0.99 and rating with PG-13
5.Retrieve the first 5 rows of movies sorted alphabetically by title.
SELECT title FROM film ORDER BY title ASC LIMIT 5;
Meaning : It Return the first 5 rows from the title column
6.Skip the first 10 rows and fetch the next 3 movies with the highest replacement cost.
SELECT title , replacement_cost FROM film ORDER BY replacement_cost DESC OFFSET 10 LIMIT 3;
Meaning : It returns the title , replacement_cost with highest 3 and skip the first 10 rows
7.Find all movies where the rating is either 'G', 'PG', or 'PG-13'.
SELECT title , rating FROM film WHERE rating = 'G' OR 'PG' OR 'PG-13';
Meaning : It returns all the title with ratings of G or PG or PG-13
8.Find all movies with a rental rate between $2 and $4.
SELECT title , rental_rate FROM film WHERE rental_rate > 2 AND rental_rate < 4;
Meaning : It return the title with rental_rate between 2 and 4
9.Find all movies with titles that start with 'The'.
SELECT title FROM film WHERE title LIKE 'The%';
Meaning : It return all the title where title name start with "The"
10.Find the first 10 movies with a rental rate of $2.99 or $4.99, a rating of 'R', and a title containing the word "Love".
SELECT title , rental_rate , rating FROM film WHERE rental_rate = 2.99 OR rental_rate = 4.99 AND renting = 'R' AND title LIKE '%Love%' LIMIT 10;
Meaning : It return the title with LOVE word and rental rate with 2.99 or 4.99 and renting is equl to "R"
11.Find all movies where the title contains the % symbol.
SELECT title FROM film WHERE title LIKE '%\%%' ESCAPE '\';
Meaning: It returns all movie titles that contain the percent (%) symbol anywhere in the title
12.Find all movies where the title contains an underscore (_).
SELECT title FROM film WHERE title LIKE '%_%' ESCAPE '\';
Meaning: It returns all movie titles that contain an underscore (_) anywhere
13.Find all movies where the title starts with "A" or "B" and ends with "s".
SELECT title FROM film WHERE (title LIKE 'A%' OR title LIKE 'B%') AND title LIKE '%s';
Meaning: It returns all movie titles starting with "A" or "B" and ending with "s"
14.Find all movies where the title contains "Man", "Men", or "Woman".
SELECT title FROM film WHERE title LIKE '%Man%' OR title LIKE '%Men%' OR title LIKE '%Woman%';
Meaning: It returns all movie titles that contain the words "Man", "Men", or "Woman" anywhere in the title
15.Find all movies with titles that contain digits (e.g., "007", "2", "300").
SELECT title FROM film WHERE title ~ '[0-9]';
Meaning: It returns all movie titles that contain any number (0–9) in the title
16.Find all movies with titles containing a backslash ()
SELECT title FROM film WHERE title LIKE '%\%' ESCAPE '\';
Meaning: It returns all movie titles that contain a backslash () anywhere
17.Find all movies where the title does contain the words "Love" or "Hate".
SELECT title FROM film WHERE title LIKE '%Love%' OR title LIKE '%Hate%';
Meaning: It returns all movie titles that contain "Love" or "Hate" anywhere in the title.
18.Find the first 5 movies with titles that end with "er", "or", or "ar".
SELECT title FROM film WHERE title LIKE '%er' OR title LIKE '%or' OR title LIKE '%ar' LIMIT 5;
Meaning: It returns the first 5 movie titles that end with "er", "or", or "ar"
Top comments (0)