To 🔥 celebrate the holiday season, Also check out our NEWLY launched Annual plan (Up to 50% off). Use coupon code THANKSGIVING15 and enjoy additional 15% off all paid plans. Coupon expires at 2020/11/30 .
40. Top 5 most rented movie in June 2020 medium

Instruction

  • Write a query to return the film_id and title of the top 5 movies that were rented the most times in June 2020
  • The order of your results doesn't matter.
  • If there are ties, return any 5 of them.

Table 1: film

       col_name       |  col_type
----------------------+--------------------------
 film_id              | integer
 title                | text
 description          | text
 release_year         | integer
 language_id          | smallint
 original_language_id | smallint
 rental_duration      | smallint
 rental_rate          | numeric
 length               | smallint
 replacement_cost     | numeric
 rating               | USER-DEFINED
 last_update          | timestamp with time zone

  

Table 2: rental

   col_name   | col_type
--------------+--------------------------
 rental_id    | integer
 rental_ts    | timestamp with time zone
 inventory_id | integer
 customer_id  | smallint
 return_ts    | timestamp with time zone
 staff_id     | smallint
 last_update  | timestamp with time zone

  

Table 3: inventory

Each row is unique; Inventoy_id is the primary key of the table

   col_name   | col_type
--------------+--------------------------
 inventory_id | integer
 film_id      | smallint
 store_id     | smallint
 last_update  | timestamp with time zone

  

Sample results

film_id  |       title
---------+--------------------
   12345 | MOVIE TITLE 1
   12346 | MOVIE TITLE 2
   12347 | MOVIE TITLE 3
   12348 | MOVIE TITLE 4
   12349 | MOVIE TITLE 5

Subscribe for solution