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 daily_rentals as ( select dayname(rental_date) as day_of_week, count(*) as rentals_count, (dayofweek(rental_date) + 5) % 7 as day_order from rental group by day_of_week, day_order ), total_rentals as ( select sum(rentals_count) as total from daily_rentals ) select day_of_week, rentals_count, (rentals_count / (select total from total_rentals)) * 100 as day_rate from daily_rentals order by day_order

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

Copy Clear