Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular

SQLize.online is a free online SQL environment for quickly running, experimenting with and sharing code. You can run your SQL code on top of the most popular RDBMS including MySQL, MariaDB, SQLite, PostgreSQL, Oracle and Microsoft SQL Server.

Copy Format Clear
Найдите клиентов которые встречали друг друга в одном из пунктов проката. Выведите таблицу с полями meet_time - согласно времени аренды, store_id - место встречи, customers список встречавшихся клиентов в формате JOHN SHOW,DAENERYS TARGARYEN - в порядке их фамилий. Результирующую таблицу отсортируйте по времени встречи и номеру пункта проката (Клиенты встречались если брали в аренду фильмы в одном отделении в одно время. Место встречи определяется местом работы сотрудника.) SELECT r1.rental_date AS meet_time, c1.store_id AS store_id, CONCAT(c1.first_name, ' ', c1.last_name) AS customer, CONCAT(c2.first_name, ' ', c2.last_name) AS customer FROM rental r1 JOIN rental r2 ON r1.store_id = r2.store_id AND r1.rental_date = r2.rental_date 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 ORDER BY r1.rental_date, r1.store_id

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear