SQLize Online / PHPize Online  /  SQLtest Online

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

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear