select p_product
from (select p_product, count(p_product)
from rental
group by p_product
order by count(p_product) desc LIMIT 5);
Error: Every derived table must have its own alias
select p_product
from (select p_product, count(p_product)
from rental
group by p_product
order by count(p_product) desc LIMIT 5);
Error: Every derived table must have its own alias
Add an alias to the subquery:
select p_product
from (
select p_product,
count(p_product)
from rental
group by p_product
order by count(p_product) desc LIMIT 5
) t;
------^ here
Also, you dont really need a subquery:
select p_product
from rental
group by p_product
order by count(p_product) desc LIMIT 5