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 st.store_id, ceil(round(avg(customer_amount), 2)) as avg_customer_payment from (select cu.store_id, cu.customer_id, sum(pa.amount) as customer_amount from payment pa inner join rental re on pa.rental_id = re.rental_id inner join customer cu on re.customer_id = cu.customer_id group by cu.store_id, cu.customer_id ) as customers_sum_amount inner join store st on customers_sum_amount.store_id = st.store_id group by st.store_id order by st.store_id

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

Copy Clear