SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
WITH film_ranking AS ( SELECT f.title AS film_title, COUNT(i.inventory_id) AS rental_count, DENSE_RANK() OVER (ORDER BY COUNT(i.inventory_id) DESC, f.title) AS film_rank FROM rental r JOIN inventory i ON r.inventory_id = i.inventory_id JOIN film f ON i.film_id = f.film_id WHERE YEAR(r.rental_date) = 2005 GROUP BY f.film_id ) SELECT film_rank, film_title FROM film_ranking WHERE film_rank <= 3 ORDER BY film_rank, film_title;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear