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 r1.rental_date AS meet_time, s.store_id AS store_id, GROUP_CONCAT(DISTINCT CONCAT(c.first_name, ' ', c.last_name) ORDER BY c.last_name SEPARATOR ',') AS customers FROM rental r1 JOIN rental r2 ON r1.rental_date = r2.rental_date AND r1.rental_id != r2.rental_id AND r1.customer_id != r2.customer_id JOIN customer c1 ON r1.customer_id = c1.customer_id JOIN customer c2 ON r2.customer_id = c2.customer_id JOIN staff st ON r1.staff_id = st.staff_id JOIN store s ON st.store_id = s.store_id JOIN customer c ON c.customer_id IN (r1.customer_id, r2.customer_id) WHERE r1.customer_id < r2.customer_id GROUP BY r1.rental_date, s.store_id ORDER BY meet_time, store_id;

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

Copy Clear