SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
with total_films as ( select count(distinct f.film_id) from film f ) select t2.category, t2.cnt * 100 / (select * from total_films) as relative_rentals_count from ( select c.name as category, count(distinct t1.film_id) as cnt from category c join ( select fc.category_id, f.film_id from film_category fc left join film f on fc.film_id = f.film_id ) t1 on c.category_id = t1.category_id group by category ) as t2

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear