SQL Explorer
Demo Environment
This environment resets nightly. Any data or connections you add are public.
SQL Explorer
New Query
Playground
Connections
Logs
Favorites
Movie recommendations
Title
default
northwind.db
sqlite-sakila.db
job_skills_1.db
job_postings_1.db
job_summary_1.db
tq
transactions_1.db
history_1390634-1970-01-01-MAX_1.db
IMDbMovies-Clean_1.db
179146-Activity_2024-07-12_07-47_101208779_1.db
vehicles_1.db
Connection
please recommend 3 movies i might want to watch. Look at the most popular few movies from each category (based on # of rentals) and then recommend a random set, so that i get some different suggestions each time i refresh.
Description
SQL
WITH rental_counts AS (SELECT f.film_id, f.title, fc.category_id, COUNT(r.rental_id) AS rental_count FROM rental r JOIN inventory i ON r.inventory_id = i.inventory_id JOIN film f ON i.film_id = f.film_id JOIN film_category fc ON f.film_id = fc.film_id GROUP BY f.film_id, fc.category_id), popular_films AS (SELECT film_id, title, category_id, rental_count, ROW_NUMBER() OVER (PARTITION BY category_id ORDER BY rental_count DESC) AS rn FROM rental_counts) SELECT film_id, title FROM popular_films WHERE rn <= 3 -- Limit to the most popular few films per category ORDER BY RANDOM() -- Randomly select 3 films LIMIT 3;
Save & Run
Save Only
Download...
CSV
JSON
Show Schema
Hide Schema
Format
SQL Assistant
Assistant prompt
"Ask Assistant" to try and automatically fix the issue. The assistant is already aware of error messages & context.
Select All
(?)
Search tables
Ask Assistant
Loading...
Preview
Pivot
  Execution time: 29.92 ms
Showing
of 3 total rows.
film_id
title
Sum
1312.0
Avg
437.33
Min
127.0
Max
767.0
NUL
0.0
0
127
CAT CONEHEADS
1
767
SCALAWAG DUCK
2
418
HOBBIT ALIEN
Link to this
Download CSV
Avg. execution: 47.097ms. Query created by admin on 2024-05-17.
History