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
tq
base
history_1390634-1970-01-01-MAX_1.db
RMS
179146-Activity_2024-07-12_07-47_101208779_1.db
job_summary_1.db
vehicles_1.db
job_skills_1.db
IMDbMovies-Clean_1.db
sqlite-sakila.db
northwind.db
transactions_1.db
organizations-100000_1.db
maestro-v3.0.0_1.db
job_postings_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: 39.23 ms
Showing
of 3 total rows.
film_id
title
Sum
2077.0
Avg
692.33
Min
609.0
Max
738.0
NUL
0.0
0
730
RIDGEMONT SUBMARINE
1
738
ROCKETEER MOTHER
2
609
MUSCLE BRIGHT
Link to this
Download CSV
Avg. execution: 55.085ms. Query created by admin on 2024-05-17.
History