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 title, first_customer From ( Select concat(c.first_name, ' ', c.last_name) first_customer , f.title , row_number() over (partition by f.title order by r.rental_date) rk from rental r join inventory i on r.inventory_id = i.inventory_id join customer c on c.customer_id = r.customer_id join film f on f.film_id = i.film_id join film_category fc on fc.film_id = f.film_id join category ct on ct.category_id = fc.category_id where f.rating = 'PG-13' and ct.name = 'Horror' )t Where rk = 1 */ Select concat(c.first_name, ' ', c.last_name) first_customer , f.title -- , row_number() over (partition by f.title order by r.rental_date) rk , first_value(r.rental_date) (partition by f.title order by concat(c.first_name, ' ', c.last_name)) from rental r join inventory i on r.inventory_id = i.inventory_id join customer c on c.customer_id = r.customer_id join film f on f.film_id = i.film_id join film_category fc on fc.film_id = f.film_id join category ct on ct.category_id = fc.category_id where f.rating = 'PG-13' and ct.name = 'Horror'

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

Copy Clear