SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
select c.last_name, c.first_name, t1.cnt from customer c join ( select r.customer_id, dense_rank() over(order by count(*) desc) as customer_rank, count(*) as cnt from rental r group by r.customer_id ) t1 on c.customer_id = t1.customer_id where t1.customer_rank <= 3 order by t1.cnt desc, c.last_name asc ; show status like 'Last_query_cost';

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear