SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
SELECT category.name, film.title AS most_rented_film, COUNT(rental.rental_id) AS rentals_count FROM rental JOIN inventory ON rental.inventory_id = inventory.inventory_id JOIN film ON inventory.film_id = film.film_id JOIN film_category ON film.film_id = film_category.film_id JOIN category ON film_category.category_id = category.category_id WHERE YEAR(rental.rental_date) = 2005 GROUP BY category.name, film.title, rentals_count ORDER BY category.name ASC, rentals_count DESC HAVING COUNT(rentals_count) = (SELECT COUNT(rentals_count) FROM rental GROUP BY customer_id ORDER BY COUNT(rentals_count) DESC LIMIT 1)

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear