7. Subquery
Subquery
Example 1 (get films whose rental rate is higher than average rental rate)
SELECT
film_id,
title,
rental_rate
FROM
film
WHERE
rental_rate > (
SELECT
AVG (rental_rate)
FROM
film
);Example 2 (get films that have returned rate between two dates)
Example 3 (get customers who have paid)
ANY

Example 1 (get films whose category is either Action or Drama)
ALL

Example 1 (find all films whose lengths are greater than the list of the average lengths)

EXISTS

Example 1 (Find customers who have at least one payment whose amount is greater than 11)

Last updated