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 f.title, f.film_id, r.rental_date, r.return_date, p.payment_date, f.rental_rate, (f.rental_rate - p.amount) as lateness_penalty, p.amount from payment as p join rental as r on p.customer_id = r.customer_id join inventory as i on r.inventory_id = i.inventory_id join film as f on i.film_id = f.film_id where p.customer_id = (select customer_id from customer where first_name = 'DOROTHY' and last_name = 'TAYLOR') and year(rental_date) = 2005 and month(rental_date) = 8 and month(payment_date) = 8 UNION ALL select 'Total' AS title, NULL AS film_id, NULL AS rental_date, NULL AS return_date, NULL AS payment_date, sum(f.rental_rate), sum(f.rental_rate - p.amount), sum(p.amount) from payment as p join rental as r on p.customer_id = r.customer_id join inventory as i on r.inventory_id = i.inventory_id join film as f on i.film_id = f.film_id where p.customer_id = (select customer_id from customer where first_name = 'DOROTHY' and last_name = 'TAYLOR') and year(rental_date) = 2005 and month(rental_date) = 8 and month(payment_date) = 8 order by payment_date; ; show status like 'Last_query_cost';

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

Copy Clear