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
select c.name as category, avg(f.rental_rate*f.rental_duration) as avg_rental_rate, avg(p.amount) as avg_payment_amount from film f join film_category fc on f.film_id=fc.film_id join category c on fc.category_id=c.category_id join inventory i on fc.film_id=i.film_id join rental r on i.inventory_id=r.inventory_id join payment p on r.customer_id=p.customer_id group by c.name order by avg_rental_rate, (p.amount-f.rental_rate*f.rental_duration) desc;

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

Copy Clear