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 avg_rental AS ( SELECT ROUND(AVG(DATEDIFF(return_date, rental_date))) as average_rental_time FROM rental ) SELECT film_id, title, ROUND(AVG(DATEDIFF(return_date, rental_date))) as average_rental_time FROM film JOIN inventory USING(film_id) JOIN rental USING(inventory_id) GROUP BY film_id, title HAVING ROUND(AVG(DATEDIFF(return_date, rental_date))) < (SELECT * FROM avg_rental)

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

Copy Clear