3. Top 5 shortest movies

easy

Instruction
  • Write a query to return the titles of the 5 shortest movies by duration.
  • The order of your results doesn't matter.

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
---------------------
 MOVIE 1
 MOVIE 2
 MOVIE 3
 MOVIE 4
 MOVIE 5

Solution postgres

SELECT title
FROM film
ORDER BY length
LIMIT 5;
    

Explanation

This query retrieves the names of the top 5 shortest films in a database table called "film". It does this by selecting the "title" column in the table and ordering the results by the "length" column (presumably the duration of the film). The "LIMIT 5" clause at the end ensures that only the top 5 results are returned.

Last Submission postgres

Expected results



More SELECT, WHERE, AND, OR, ORDER BY, LIMIT questions

ID Title Level FTPR
228 Analyzing Sequential Purchase Behavior microsoft hard -
227 Aggregate Sale Amounts per Customer microsoft hard -
226 Customer Lifetime Value (CLV) and Segmentation microsoft hard -
225 Customer Behavior Analysis microsoft hard -
224 Categories with High Average Product Price microsoft medium -
223 Cumulative Total Sales by Day microsoft hard -
222 Product Sales Ranking Within Categories microsoft hard -
221 Customers With More Than 5 Products in a Single Transaction microsoft hard -
220 Most Expensive Product in Each Category microsoft hard -
219 Inactive Customers in the New Year of 2024 microsoft medium -
218 Total Amount Spent by Each Customer microsoft medium -
217 Most engaged customers roblox hard
10%
210 Issuer and merchant report visa easy
100%
200 Last week's absent students snap medium
67%
175 Employees' email account amazon easy
14%
152 Salary analysis dropbox easy
20%
126 Top 3 restaurants uber hard
10%
111 Second most popular product amazon medium
16%
92 Acceptance rate first week of 2021 spotify easy
14%
17 GROUCHO WILLIAMS’ actor_id easy
57%
16 Staff who live in Woodridge easy
65%
4 Staff without a profile image easy
66%
2 Top 3 movie categories by sales easy
42%
1 Top store for movie sales easy
24%