Question 25

Shortest film

Instruction
  • Write a query to return the title of the film with the minimum duration.
  • A movie's duration can be found using the length column.
  • If there are ties, e.g., two movies have the same length, return either one of them.

Table: 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               | text

Sample results

    title
--------------
 SHORT FILM

Solution

postgres
SELECT title
FROM film
ORDER BY length
LIMIT 1;

Explanation

This query selects the title of a movie from the "film" table in a Postgres database. It orders the results by the length of the movie (in minutes) in ascending order. It then limits the output to just one result, which will be the movie with the shortest length.

Copied

Last Submission

postgres

No submission yet for this engine. Run and submit your query to save it here.

Copied
Expected results

Submit a query to compare against expected output.