Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
WITH film_ranking AS ( SELECT f.title AS film_title, COUNT(r.rental_id) AS copies_count, DENSE_RANK() OVER (ORDER BY COUNT(r.rental_id) DESC) AS film_rank FROM film f JOIN rental r ON f.film_id = r.inventory_id -- Предполагается, что inventory_id соответствует film_id WHERE YEAR(r.rental_date) = 2005 GROUP BY f.title ) SELECT film_rank, film_title FROM film_ranking WHERE film_rank <= (SELECT MAX(film_rank) FROM film_ranking WHERE film_rank <= 3) ORDER BY film_rank, film_title LIMIT 5; -- Ограничение на вывод первых 5 строк ; show status like 'Last_query_cost';

Stuck with a problem? Got Error? Ask AI support!

Copy Clear